我每天都有netowrk路由器利用文件。我正在尝试为每个唯一路由器(QIN)及其发生的时间找到列uIN和uOUT的最大值。
我和Pandas以及'groupby'做了很多,但似乎无法获得我需要的最终结果。
以下是数据样本:
Minute QIN uIN uOUT
2/14/2018 16:00 Bundle-Ether1 on (Router1.network.com) 0.10221 0.21195
2/14/2018 16:05 Bundle-Ether1 on (Router1.network.com) 0.089865 0.18722
2/15/2018 16:10 Bundle-Ether1 on (Router1.network.com) 0.07482 0.1705
2/16/2018 16:15 Bundle-Ether1 on (Router1.network.com) 0.09176 0.18846
2/17/2018 16:20 Bundle-Ether1 on (Router1.network.com) 0.11816 0.11785
2/14/2018 16:00 Bundle-Ether1 on (Router2.network.com) 0.08786 0.15235
2/14/2018 16:05 Bundle-Ether1 on (Router2.network.com) 0.07777 0.19253
2/15/2018 16:10 Bundle-Ether1 on (Router2.network.com) 0.07552 0.14232
2/16/2018 16:15 Bundle-Ether1 on (Router2.network.com) 0.1291 0.18758
2/17/2018 16:20 Bundle-Ether1 on (Router2.network.com) 0.13361 0.11747
这是我的代码:
import pandas as pd
df = pd.read_csv('c://router_data.csv')
df['Minute'] = pd.todatetime(df['Minute'])
df.set_index('Minute').groupby('QIN')['uIN'].resample("M").max()
结果:
Bundle-Ether1 on (Router2.network.com) 0.13361
Bundle-Ether1 on (Router1.network.com) 0.11816
我需要的结果:
2/17/2018 16:20 Bundle-Ether1 on (Router2.network.com) 0.13361
2/17/2018 16:20 Bundle-Ether1 on (Router1.network.com) 0.11816
答案 0 :(得分:1)
我建议合并。你可以放弃' uOUT'如果有必要的话。
0606094D734F