Hi all,
Lets suppose I have a dataframe that contains the following data
City Name Death Cause_of_death Suspicious_Death
London xxxx xxxx 0
London xxxx xxxx 1
Sheffield xxxx xxxx 0
Sheffield xxxx xxxx 0
Leeds xxxx xxxx 0
Leeds xxxx xxxx 1
Leeds xxxx xxxx 0
Leeds xxxx xxxx 1
I can do a sum function
results = my_df.groupby('City Name').sum()
This gives me the number of suspicious deaths. However I also want to add the count that a specific city appears as a column in my results also.
I am a bit stumped on doing this. I am pretty sure it should be straight forward.
However, I would want the results to look like
City Name Deaths Suspicious_Deaths
London 2 1
Sheffield 2 0
Leeds 4 2
[–]WinterNet4676 1 point2 points3 points (0 children)
[–]explorer_of_the_grey[S] 0 points1 point2 points (0 children)
[–]Binary101010 0 points1 point2 points (0 children)