0

How can I resample my dataframe over multiple columns to obtain a new statistic?

For example, I have a dataframe with indexed by seconds with two columns (amount, quantities) and I would like to resample() to minutes to a new column based on amount * quantities .

DSPNewbie
  • 33
  • 5

1 Answers1

0

IIUC you need resample with some aggreagte function like sum, mean and then multiple columns:

df = df.resample('T').sum()
df['new'] = df.amount * df.quantities
jezrael
  • 822,522
  • 95
  • 1,334
  • 1,252
  • Thanks @Jezrael, in this example, this would work but imagine I wanted to get the correlation between amount and quantities. – DSPNewbie Jan 10 '17 at 11:47
  • Welcome to StackOverflow. Please take the time to read this post on [how to provide a great pandas example](http://stackoverflow.com/questions/20109391/how-to-make-good-reproducible-pandas-examples) as well as how to provide a [minimal, complete, and verifiable example](http://stackoverflow.com/help/mcve) and revise your question accordingly. These tips on [how to ask a good question](http://stackoverflow.com/help/how-to-ask) may also be useful. – jezrael Jan 10 '17 at 11:48