python-3.x - 使用python的每个小时的月平均值
问题描述
我有如下数据
Date_Time A
2019-09-01 00:00:00 140.857143
2019-09-01 01:00:00 132.8750000
... ... ... ... ...
2019-09-30 22:00:00 120.419355
2019-09-30 23:00:00 110.285714
我想平均每个月 9 月(第 9 个月)的每个小时,如下所示使用 python
Date_Time A
00:00:00 value
01:00:00 value
..............
23:00:00 value
所以基本上是每个小时的月平均值。如何做到这一点请提出任何建议。
解决方案
我们试试看:
# remove `.dt.floor('H')` if your data is already hourly
hours = df['Date_Time'].dt.floor('H').dt.strftime('%H:%M:%S')
df.groupby(hours)['A'].mean()
推荐阅读
- arrays - 不寻常的 bash 数组命令
- c# - 如何为一个项目创建多个序列
- jwt - featherjs 错误:不允许创建 JWT (`jwtStrategies`) 的身份验证策略
- python-3.x - 我应该如何使用单变量样条来拟合特定形状的数据?
- javascript - 将链接属性设置为元素不起作用并且无法弄清楚原因
- objective-c - 自定义表格视图单元格的自动布局
- laravel - 在 Lumen 中更改环境文件路径
- java - 无状态注释是否会传播到抽象类的扩展?
- python - 努力从 python3 中的论文中用 DEAP 实现差分进化算法
- spring - Feign Client 中的 RequestParam 不支持 Spring Data Pageable