简体   繁体   中英

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:

在此处输入图像描述

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!

How about this?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM