I have a dataframe that I would like to group by one column (dadate) and then query another column (Place) to count only those with the value 1.
Leaguedata.groupby(['dadate']).query('Place == "1"').Place.count()`
The above is what I have tired with the error “‘DataFrameGroupBy’ object has no attribute ‘query'”
Advertisement
Answer
Create the Boolean Series then sum that within group to see how many Places == 1 for each group.
Leaguedata['Place'].eq('1').groupby(Leaguedata['dadate']).sum()