Why I cannot get major labels on the x-axis?
Many thanks in advance.
You are calling
.plot.bar() on a Series, you need to use it on the
recent_grads[163:] DataFrame. So change your code to this:
recent_grads[163:].plot.bar(x="Major", y="ShareWomen", legend=False)
Hope this helps
Why here we used major ??? in X columns ? and why we using legen=false, there was no evidence of legend=false in the project learn section.
and why everyone is using recent_grads[163:] ???
where in the instruction its clearly mention
Use bar plots to compare the unemployment rate (
Unemployment_rate ) from the first ten rows and last ten rows of the
Since the plot used in this topic is related to the first instruction, I will use it help you with your query.
Use bar plots to compare the percentages of women (
ShareWomen) from the first ten rows and last ten rows of the
Why are we using the
Major column as x-axis values?
recent-grads.csv dataset, each row represents a major. This is why we used that column as x-axis values to compare the percentages of women. None of the other columns would make sense.
Why are we using
There is no need to use
legend=False. However, if we don’t use it, the plot will appear like this:
As you can see, the legend doesn’t make much sense here.
Why are we using
If you execute
recent_grads.tail(10), you will see that the last 10 rows start from index label
163. So we are using it here. However, it’s not necessary to explicitly use the starting index, we can just do:
recent_grads.tail(10).plot.bar(x="Major", y="ShareWomen", legend=False) to obtain the same results.
I hope it helps .
Thank You Sahil for helping and clearing my doubts.