根据时间python查找最大值和下降行
我试图根据电台列和有效列的小时找到REC的最大值。我没有可行的代码,因为我一直在尝试这种情况,而且还没有发现工作解决方案。
框
电台 | 合作 | 与 |
---|---|---|
数据 | 是 | 正在 |
我 | 这 | 的 |
| | |
| 02-23 08:07:00 | 0.1 |
1V4 | 2022-02-23 08:51:00 | 0.6 |
BTV | 2022-02-23 07:52:00 | 0.1 |
BTV | 2022-02-23 | 07 |
:54:54: 00 | : 54 23 07:59:00 | 0.3 |
BTV | 2022-02-23 08:02:00 | 0.0 |
BTV | 2022-02-23 08:16:00 | 0.0 |
BTV | 08:29:00 | 0.3 |
2022-02-23 看起来像
站 | 有效 | 爆炸 |
---|---|---|
1V4 | 2022-02-23 07:58:00 | 0.4 |
1V4 | 2022-02-23 08:51:00 | 0.6 |
BTV | 2022-02-23 07:59:00 | 0.3 0.3 |
BTV | 20222-202-23 08:29 :00 | 0.3 |
I am trying to find the maximum value of precip based on the station column and the hour of the valid column. I have no workable code as I've been trying this forever and have found no even close to working solution.
Here is the dataframe I am working with
station | valid | precip |
---|---|---|
1V4 | 2022-02-23 07:54:00 | 0.2 |
1V4 | 2022-02-23 07:55:00 | 0.2 |
1V4 | 2022-02-23 07:58:00 | 0.4 |
1V4 | 2022-02-23 08:07:00 | 0.1 |
1V4 | 2022-02-23 08:51:00 | 0.6 |
BTV | 2022-02-23 07:52:00 | 0.1 |
BTV | 2022-02-23 07:54:00 | 0.2 |
BTV | 2022-02-23 07:59:00 | 0.3 |
BTV | 2022-02-23 08:02:00 | 0.0 |
BTV | 2022-02-23 08:16:00 | 0.0 |
BTV | 2022-02-23 08:29:00 | 0.3 |
This is what I want it to look like
station | valid | precip |
---|---|---|
1V4 | 2022-02-23 07:58:00 | 0.4 |
1V4 | 2022-02-23 08:51:00 | 0.6 |
BTV | 2022-02-23 07:59:00 | 0.3 |
BTV | 2022-02-23 08:29:00 | 0.3 |
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要按车站和小时分组,并获取
idxmax
,然后切片:输出:
You need to group by station and hour and get the
idxmax
, then slice:output:
这将使您能够按小时和车站进行分组
This will allow you to group by the hour and the station