问题
I am preprocessing apache server log data. I have 3 columns ID, TIME, and BYTES. Example:
ID     TIME     BYTES
1     13:00     10
2     13:02     30
3     13:03     40
4     13:02     50
5     13:03     70
I want to achieve something like this:
ID     TIME     BYTES
1     13:00     10
2     13:02     80
3     13:03     110
回答1:
Let's try:
df['TIME'] = pd.to_datetime(df['TIME'])
ax = df.groupby('TIME')['BYTES'].sum().plot()
ax.set_xlim('13:00:00','13:03:00')
Output:
来源:https://stackoverflow.com/questions/48013007/group-duplicate-columns-and-sum-the-corresponding-column-values-using-pandas