Why does pd.df.rolling.aggregate takes so much longer when the input is a list?

Viewed 54

I'm using python 3.8.3 and pandas 1.1.5.

table_in.T is a 18 by 209997 pandas dataframe. window and periods are both set to 12.

The following three lines of code respectively takes 9.52s, 6.27s and 5min53s to run.

rolledsum2_in = table_in.T.rolling(window, min_periods=periods).agg('sum')
rolledmean2_in = table_in.T.rolling(window, min_periods=periods).agg('mean')
rolledsumean_in = table_in.T.rolling(window, min_periods=periods).agg(['sum','mean'])

Why does it take so much longer when aggregating the rolling object by sum and mean together than doing them separately?

0 Answers
Related