0

I'm trying to learn how to use pandas and im trying to display a plot showing the total births by sex & year.

[1] [https://i.sstatic.net/R7Vz7.png] (Cant figure out why there's another column called sex

but this image above the data im trying to plot

and keep getting TypeError: Empty 'DataFrame': no numeric data to plot)

This is what my code looks like

[2] https://i.sstatic.net/FbZmM.png

1 Answer 1

1

This is happening because during the pivot the dataFrame becomes multi-indexed. There are no columns with values to plot against eachother. You can use df.reset_index() to set the multiple indexes as columns, and then plot their values.

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

Comments

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.