I have a dataframe which is a list of organisations (multiple rows per organisation) which has a boolean
value associated with it.
So organisation A has 3 true
rows and 3 false
i.e.
Organisation Value
A True
A True
A False
A False
A True
A False
B True
B True
C False
C False
I want to get it into the format where I have each organisation listed only once, and the true
and false
values under the value column as new column headers like this (and then counted):
Organisation True False
A 3 3
B 2 0
C 0 2
Currently by code is like this:
sqlDf.groupby(['Organisation','Value']).size().reset_index(name='counts')
But that doesnt do what I need it to do.
Any advice?