Reputation: 79
I have a dataframe that looks something like this:
airline review
United neutral
United neutral
United negative
Southwest negative
Delta positive
Delta positive
I then converted it into a pivot table:
a = pd.pivot_table(df, index = ['airline', 'review'], aggfunc = len)
a
airline review
United neutral 2
United negative 1
Southwest negative 1
Delta positive 2
Then plotted:
a.plot(kind = 'bar')
How can I get each airlines reviews to plot together as different colors for each type of review, all sorted together (much like a pivot chart would in Excel)?
Thanks in advance!
Upvotes: 1
Views: 5686
Reputation: 214927
You just need to unstack the reviews
index as columns:
a.unstack('review').plot(kind='bar')
Upvotes: 1