简体   繁体   中英

How to aggregate data in a csv file using python?

I have a csv file written in this format:

timestamp,user_holding
07/12/2018 00:45,23
07/12/2018 01:45,48
07/12/2018 06:45,67
08/12/2018 07:45,12
08/12/2018 13:45,35
08/12/2018 18:45,67
.....

What i need to do is to aggregate the user_holding per day so that I have:

timestamp,user_holding
07/12/2018,138
08/12/2018,114
....

I have to use python to to that because I need to do it for a lot of files, is there a fast way to do that? Thanks in advance!

Use regex. First remove those commas. Then add the commas where u need them to be.

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