【发布时间】:2021-03-25 14:18:23
【问题描述】:
这段代码
print(loc_coverage)
loc_coverage2 = loc_coverage.groupby('date').min()
print(loc_coverage2)
产生这个输出
date location_coverage
0 2021-03-25 22.38
1 2021-03-25 22.38
2 2021-03-25 22.38
location_coverage
date
2021-03-25 22.38
2021-03-25 22.38
我原以为只有一排。为什么日期值没有分组?
日期是一个 datetime.date 对象,我检查过没有重复。
【问题讨论】:
-
如果日期是一个字符串,它可能有尾随空格..检查一下
-
我猜有一些空间,之前
-
请不要发布代码、数据或 Tracebacks 的图像。将其复制并粘贴为文本,然后将其格式化为代码(选择它并输入
ctrl-k)...Discourage screenshots of code and/or errors...Why not upload images of code on SO when asking a question?...You should not post code as an image because:... -
那么可以测试
print(loc_coverage['date'].unique())吗?
标签: python pandas pandas-groupby