使用Python将相同的DateTime值求和相同的DateTime值
我有一个带有DateTime列的DataFrame,我试图以相同的DateTime以所有值的总和来获得打印,然后在所有值之后进行平均值。 这是我所拥有的:
df[col] = pd.to_datetime(df[col]).dt.date
df.groupby([col]).sum()
但是我只是从所有日期打印出来,而不是它们与它们相关的值
Date_Recieved
2017-01-01
2017-01-02
2017-01-03
2017-01-04
2017-01-05
之后出现的频率,我希望保存所有值并进行单个平均值
I have a dataframe with a datetime column, I am trying to get the print out of the sum of all the values with the same datetime and then do an average afterwards of all the values.
Here is what I have:
df[col] = pd.to_datetime(df[col]).dt.date
df.groupby([col]).sum()
But I just get a print out of all the dates and not their associated values with how often they appear
Date_Recieved
2017-01-01
2017-01-02
2017-01-03
2017-01-04
2017-01-05
After this I was hoping to save all the values and do a single average
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论