我的数据集(dataset1)如下所示:
Date Company Weekday
2015-01-01 Company1 Monday
2015-01-02 Company1 Tuesday
2015-01-03 Company1 Wednesday
2015-01-04 Company1 Thursday
2015-12-09 Company2 Monday
2015-12-10 Company2 Tuesday
………………………………………………………………………
2016-01-08 Company3 Wednesday
2016-01-09 Company3 Thursday
然后我应用以下代码:
dataset2 = dataset1.groupby(['Company','Weekday']).size().sort_values(ascending=False)
一旦应用了以上代码,我将得到以下结果:
Index 0
('Company1', Monday) 80
('Company1', Tuesday) 80
('Company1', Wednesday) 79
………………………………………………………………….
('Company3', Tuesday) 34
我试图隔离计数值大于50的所有dataset2条目,但是尝试以下操作时会遇到各种错误:
dataset2=dataset2.loc[dataset2[0]>50]
任何人都可以发表意见吗?
答案 0 :(得分:3)
使用web_access_log
,因此需要:
Series
另一种解决方案是为dataset2 = dataset1.groupby(['Company','Weekday']).size().sort_values(ascending=False)
dataset2 = dataset2[dataset2 > 50]
添加带有参数name
的{{3}},然后按列DataFrame
进行过滤:
count