4

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?

Bakuriu
  • 98,325
  • 22
  • 197
  • 231
Guolun Li
  • 77
  • 1
  • 6
  • This is likely pretty dependent on the underlying data, you can use the `prun` and `memit` modules to see "under the hood" and check what portions of the code are using the most processor and memory – G. Anderson Dec 09 '20 at 21:56

0 Answers0