0
0
Pandasdata~10 mins

Expanding window operations in Pandas - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to calculate the expanding sum of the 'sales' column.

Pandas
df['expanding_sum'] = df['sales'].[1]().sum()
Drag options to blanks, or click blank then click option'
Acumsum
Brolling
Cexpanding
Dgroupby
Attempts:
3 left
💡 Hint
Common Mistakes
Using rolling() instead of expanding() causes a fixed window sum.
Using cumsum() directly does not use expanding window object.
2fill in blank
medium

Complete the code to calculate the expanding mean of the 'temperature' column.

Pandas
mean_temp = df['temperature'].[1]().mean()
Drag options to blanks, or click blank then click option'
Acumsum
Bexpanding
Crolling
Dgroupby
Attempts:
3 left
💡 Hint
Common Mistakes
Using rolling() instead of expanding() gives a fixed window mean.
Using cumsum() does not calculate mean.
3fill in blank
hard

Fix the error in the code to calculate the expanding maximum of the 'price' column.

Pandas
max_price = df['price'].[1]().max()
Drag options to blanks, or click blank then click option'
Aexpanding
Bgroupby
Ccumsum
Drolling
Attempts:
3 left
💡 Hint
Common Mistakes
Using rolling() gives max over fixed window, not expanding.
Using cumsum() is for sums, not max.
4fill in blank
hard

Fill both blanks to create a dictionary of expanding minimum values for words longer than 4 characters.

Pandas
expanding_min = {word: df['value'].[1]().min() for word in words if len(word) [2] 4}
Drag options to blanks, or click blank then click option'
Aexpanding
B>
C<
Drolling
Attempts:
3 left
💡 Hint
Common Mistakes
Using rolling instead of expanding for the window.
Using < instead of > for filtering word length.
5fill in blank
hard

Fill all three blanks to create a dictionary with keys as uppercase words and values as expanding mean of 'score' for scores greater than 50.

Pandas
result = [1]: df['score'].[2]().mean() for word in words if df['score'] [3] 50
Drag options to blanks, or click blank then click option'
Aword.upper()
Bexpanding
C>
Drolling
Attempts:
3 left
💡 Hint
Common Mistakes
Using rolling instead of expanding for the window.
Using < instead of > for filtering scores.
Not converting words to uppercase for keys.