Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Trying to condense data in several columns across multiple rows based on a common column value – python/pandas

I’ve got some data I’m trying to reorganize in my pandas dataframe. Here is a snippet PNG:

enter image description here

So for each Date_Time reading there are 7 rows. What I want to do is condense those 7 rows down into one. And I want to sum all the important data columns (Voltage, Current, ChargeCapacity, DischargeCapacity, ChargeEnergy, DischargeEnergy, and dV/dt(V/s). Thank you!

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

How about this ?

df.groupby("Date_Time")[["Voltage", "Current", "ChargeCapacity", "DischargeCapacity", "ChargeEnergy", "DischargeEnergy", "and dV/dt(V/s)"]].sum()
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading