Open richardshiii opened 5 years ago
If I understand correctly, you can just use groupby function.
.groupby("types of crime " , "year ").size()
I think groupby function is a kind of way to deal with your problem. In this way, you will know the number of the type of crimes is each year. ...groupby("type of crime","year").size() Hope that will help you.
I solved a similar problem by creating a new dataframe to reflect the data that I want to count, then type the code len() to know how many rows it has! I think groupby can solve this problem as well!
Hi all,
My dataset contains different types of crime and when they happened (in which year). I would like to count the number of a specific type of crime happened in each year. Does anyone has any ideas on how do write the codes?
Thanks a lot!
Kewei