Star Wars Survey. Need help with a bar chart

Screen Link:
https://app.dataquest.io/m/201/guided-project%3A-star-wars-survey/8/exploring-the-data-by-binary-segments

My Code:

edu_rank = edu.groupby('Education')[edu.columns[9:15]].mean()

## reindexing columns' labels
edu_rank.columns = edu_rank.columns.str.replace('ranking_','Episode ')

edu_rank

I would like to plot a barh where the y axis are the episodes and on the x axis the average ranking as grouped before

What actually happened:

edu_rank.plot(kind='barh')

But it’s plotted exactly in the reverse sense.

Would you know how could I solve this issue?

Thank you!

Hi @giovanni.srg

Too late of a response but have you tried using options like providing x and y-axis similar to ‘kind’ argument?
pandas.DataFrame.plot — pandas 1.3.0 documentation (pydata.org)

or may be a simple dataframe.T.plot(kind = "barh")
assuming you only have two columns in the edu_rank dataframe. So transpose and then plot?

Let me know if this turned out to be a lame suggestion.

1 Like

Yes!
That’s a nice suggestion. I solved before by just using transpose to invert columns and rows of the df

1 Like

Oh Cool @giovanni.srg !

1 Like