Let's say I have a dataframe that looks like this:
interview longitude latitude
1 A1 34.2 90.2
2 A1 54.2 23.5
3 A3 32.1 21.5
4 A4 54.3 93.1
5 A2 45.1 29.5
6 A1 NaN NaN
7 A7 NaN NaN
8 A1 NaN NaN
9 A3 23.1 38.2
10 A5 -23.7 -98.4
I would like to be able to perform some sort of groupby method that outputs me the total present values within each subgroup. So, desired output for something like this would be:
interview longitude latitude occurs
1 A1 2 2 4
2 A2 1 1 1
3 A3 2 2 2
4 A4 1 1 1
5 A5 1 1 1
6 A7 0 0 1
I tried to use this command to try with latitudes, but not getting the desired output:
df.groupby(by=['interview', 'latitude'])['interview'].count()
Thanks!