Reputation: 414
I have a pandas dataframe as follows
x score freq
T 49.0 2000000
T 49.0 2000000
T 49.0 2000000
T 49.0 1824000
T 49.0 856200
F 49.0 800000
F 49.0 746900
F 49.25 4060900
F 49.25 1450000
T 49.25 1000000
T 49.25 1000000
F 49.25 1000000
F 49.5 2748900
F 49.5 2000000
T 49.5 2000000
F 49.5 1834400
What I am planning to do here is to sum the rows with same 'x' and 'score' values, then plot a stacked bar with every column representing a unique 'score', with the stacks being 'T' and 'F' for the particular score.
So far, I have grouped them with
y = x.groupby(['x','score']).sum()
but I do not have enough experience with visualisations to proceed further. Any help would be greatly appreciated. Thanks!
Upvotes: 0
Views: 69
Reputation: 426
df.groupby(['x', 'score']).sum().unstack().plot(kind='bar', stacked=True)
Upvotes: 1