[英]How to group pandas dataframe rows based on two columns to find the count for each day?
Here is how my data looks: DataFrame这是我的数据的外观:DataFrame
TagID PlazaEntryTime PlazaID
0 2844106899 9/29/19 9:31:06 PM 1420
1 2844106896 10/29/19 9:31:06 PM 1421
2 2844106896 9/29/19 9:31:06 PM 1440
3 2844106896 12/29/19 9:31:06 PM 1422
I want to find the count of the number of rows each day for Plaza ID = 1420我想找到 Plaza ID = 1420 每天的行数
I used the following code:我使用了以下代码:
df['PlazaEntryTime'].groupby([df.PlazaEntryTime.dt.day,df.PlazaId==1420]).agg('count')
the output of which is the following:其输出如下:
PlazaEntryTime PlazaId Count
9 False 0
True 2
10 False 1
True 0
12 False 1
True 0
But I do not want the count of false results to be printed, can anyone tell me what am i doing wrong?但我不想打印错误结果的数量,谁能告诉我我做错了什么?
df[df['PlazaID']==1420].groupby(df.PlazaEntryTime.dt.day)['TagID'].agg('count')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.