0

I'm working with data for S&P futures. I have a dataframe of data with every 60min close and the volume traded during each 60min interval. I'd like create a new dataframe to sum up the total volume at each price.

Date Close Volume
0 4420 100
1 4420.25 200
2 4420.5 300
3 4420 200
4 4420.75 200
5 4422 300

So for example, for 4420, the total volume would be 300, whereas since there are no duplicates for the rest, their total volume would simply be the volume show.

Sorry if the formatting on this question isn't perfect, new to forums.

Appreciate any help!

Henry Ecker
  • 34,399
  • 18
  • 41
  • 57

1 Answers1

0

Use pandas groupby to perform any type of aggregation groupby

dfg = df.groupby('Close')['Volume'].agg('sum').reset_index()
Pavan Suvarna
  • 486
  • 3
  • 13