0

I have a pandas data frame and i need to combine two or more rows and add values of specific column for these rows.

Below is an example of the dataframe exported to csv

symbol,orderId,price,qty,time,isBuyer
TRXUSDT,60180710.0,0.03028,429.4,2019-05-15 05:10:03,SELL
TRXUSDT,60180710.0,0.03025,10000.0,2019-05-15 05:10:03,SELL
TRXUSDT,60180710.0,0.03024,3856.2,2019-05-15 05:10:03,SELL
TRXUSDT,60180710.0,0.03026,14630.6,2019-05-15 05:10:03,SELL

Above rows have the same symbol, orderId, time and isBuyer columns. But they have different "qty", and "price".

I would like to combine it into one row and sum the "qty" values into one single value, and the average of "price" values into single value

What is the best way to do it?

A.Midany
  • 201
  • 1
  • 5
  • 16

0 Answers0