【发布时间】:2018-06-09 22:37:45
【问题描述】:
这是原始数据。
ID     时间     字节
1     13:00     10
2     13:02     30
3     13:03     40
4     13:02     50
5     13:03     70
我使用ax = server_logs.groupby('TIME')['REPLY_SIZE'].sum() 获得了以下数据。
ID     时间     字节
1     13:00     10
2     13:02     80
3     13:03     110
做完之后如何将 TIME 和 BYTES 分成两个不同的列表?使用time = ax[0] 似乎没有分开。
ps:我想在此数据上使用 sklearn 应用 k 表示聚类。
【问题讨论】:
-
怎么样:
v = df.groupby('TIME')['BYTES'].sum(); a, b = v.index.tolist(), v.tolist()? -
不,它们是时间戳对象。您可以毫无问题地绘制它们。是的,这就是它的作用。另外,使用 pd.Series.plot 有什么问题?就像我在你上一个问题中建议的那样?
-
是的。我画了。有用。我在上一个问题中找不到您的 pd.Series.plot 。可以发在这里吗?
-
你本来可以做到的
df.groupby('TIME')['BYTES'].sum().plot():p
标签: python-3.x pandas k-means pandas-groupby sklearn-pandas