Complete the code to calculate the rolling mean with a window size of 3.
import pandas as pd data = pd.Series([1, 2, 3, 4, 5]) rolling_mean = data.[1](3).mean() print(rolling_mean)
The rolling method creates a rolling window object to perform calculations like mean.
Complete the code to calculate the rolling sum with a window size of 4.
import pandas as pd data = pd.Series([10, 20, 30, 40, 50]) rolling_sum = data.rolling([1]).sum() print(rolling_sum)
The window size is 4, so we pass 4 to the rolling method.
Fix the error in the code to calculate the rolling median with a window size of 3.
import pandas as pd data = pd.Series([5, 3, 8, 7, 10]) rolling_median = data.rolling(3).[1]() print(rolling_median)
The median method calculates the median of values in the rolling window.
Fill both blanks to create a rolling window of size 2 and calculate the maximum value in each window.
import pandas as pd data = pd.Series([4, 7, 1, 8, 5]) rolling_max = data.[1]([2]).max() print(rolling_max)
Use rolling to create the window and pass 2 as the window size to calculate max over 2 elements.
Fill all three blanks to create a rolling window of size 3, calculate the minimum value, and assign it to a new variable.
import pandas as pd data = pd.Series([9, 2, 6, 3, 7]) rolling_min = data.[1]([2]).[3]() print(rolling_min)
Use rolling with window size 3 and call min() to get the minimum in each window.