Complete the code to calculate the expanding sum of the 'sales' column.
df['expanding_sum'] = df['sales'].[1]().sum()
The expanding() method creates an expanding window object that includes all data up to the current row. Using sum() on it calculates the cumulative sum over this expanding window.
Complete the code to calculate the expanding mean of the 'temperature' column.
mean_temp = df['temperature'].[1]().mean()
The expanding() method creates a window that grows with each row, and mean() calculates the average over this window.
Fix the error in the code to calculate the expanding maximum of the 'price' column.
max_price = df['price'].[1]().max()
The expanding() method is needed to create an expanding window before applying max(). Using cumsum() or groupby() here is incorrect.
Fill both blanks to create a dictionary of expanding minimum values for words longer than 4 characters.
expanding_min = {word: df['value'].[1]().min() for word in words if len(word) [2] 4}The expanding() method creates the expanding window for the 'value' column. The condition len(word) > 4 filters words longer than 4 characters.
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.
result = [1]: df['score'].[2]().mean() for word in words if df['score'] [3] 50
The key is the uppercase version of each word using word.upper(). The expanding window is created with expanding(), and the filter uses > 50 to select scores greater than 50.