2

I have the following dataFrame:

         Score
one  A     8
     B    19
     D    29
two  C    18
     A    10
     B     4
     D     2
six  C     4
     A     4
     B     4

And I wish to create one bar plot where X axis values are "one", "two" and "six", and each value has 4 bars (A,B,C,D) when the bar height determined by the score column.

Thank you. Nastya

1
  • Can you show the code you have tried? Commented Dec 19, 2016 at 14:03

2 Answers 2

2

You need unstack for reshaping with DataFrame.plot.bar:

import matplotlib.pyplot as plt

df.unstack()['Score'].plot.bar()

plt.show()

graph

Sign up to request clarification or add additional context in comments.

Comments

0

Try the following :

df.unstack(level=1).plot(kind='bar')

1 Comment

Thanks! The graph worked, however why in the legend I have values like - (0,A), (0,B),(0,C) and(0,D), instead A,B,C,and D? Is it possible to print above each bar A/B/C/D ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.