Question

I have various sums that I've calculated from my dataframe and I want to use matplotlib...

I have various sums that I've calculated from my dataframe and I want to use matplotlib and make pi chart of percentage of students with a particular nationality.

for ex,
totalStudents=(df.sum())
studentsSwiss=(df1.sum())
studentsIndian=(df2.sum())
studentsChinese=(df3.sum())
etc.
And I want the pi chart to be in percentage. so take in those values convert to percentage of total students of that nationality. I'm using python.

additional info:
df is a dataframe that has a column that sums total Swiss, Indian, Chinese nationalities and the rows would be different schools.

df1 has a column for number of students who are Swiss, and rows would be different schools.

df2 has a column for number of students who are Indian, rows are the different schools.

df3 has a column for number of students who are Chinese, rows are the different schools.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

You do not have to convert them into percentages. You can just write the following and it will work properly:

plt.pie([studentsSwiss, studentsIndian, studentsChinese], labels=["Swiss", "Indian", "Chinese"])
plt.show()

It will create a pie plot by calculating the percentages with the given labels. We assume the following is written at the beginning of the code:

import matplotlib.pyplot as plt

Add a comment
Know the answer?
Add Answer to:
I have various sums that I've calculated from my dataframe and I want to use matplotlib...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • QUESTION 1: Why must project manager should have good technical skills but also good management skills?...

    QUESTION 1: Why must project manager should have good technical skills but also good management skills? QUESTION 2: **Communication and Communicator are related" This quote from the text suppose that the communication process is lead by the spokeperson. Do you think is it a gift" to be a good communicator or a skill to improve ( use example of your knowledge to answer)? QUESTION 3: Look at the text paragraph yellow highlighted, and do you think that in today's world...

  • can someone help with the blue reader project, please? I have the journal entries I need...

    can someone help with the blue reader project, please? I have the journal entries I need help with journal ledger and trial balance so I can I do the financial statements. thanks can someone help me the ledger and trial balance please, I posted all the information about the picture Credit The accounting cycle illustrated below is designed to provide information about a company's profitability for lack thereof) along with many other important financial characteristics. This same accounting Cycle is...

  • I got stuck on these two steps, can someone help me ? ACCOUNTING CYCLE STEP 3:...

    I got stuck on these two steps, can someone help me ? ACCOUNTING CYCLE STEP 3: Post each trans me general ledger working papers provideo teach transaction in the general journal to the general ledger. Use s provided in your packet. Posting is the process of transferring general journal entry information to the seneral ledger. Fach number you post should be properly Cross-referenced Helpful Hints by: recording the general journal page number (ex. G1, G2, etc.) in the Posting Reference...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT