I have a dataframe containing a categorical variable in one column and a continuous variable in another column like so:
gender contVar
Male 22379
Female 24523
Female 23421
Male 23831
Male 29234
I want to get a table like so:
Male Female
22379 24523
23831 23421
23831
29234
Is this possible in pandas? When I do:
df.pivot(index = df.index.tolist(), columns='gender', values='contVar')
I get that the index is out of bounds (obviously since there arent rows as there are indices but I also presume that its because the number of rows in each column are not equal). Any ideas are appreciated.