Question 5 Assign largest to a two column table with the name not the 3 letter

Question 5 assign largest to a two column table with

This preview shows page 21 - 23 out of 23 pages.

Question 5.Assignlargestto a two-column table with thename(not the 3-letter code) andpoverty_totalof the 10 countries with the largest number of people living in extreme poverty.21
Background image
In [9]:largest= ...largestIn [34]:_=ok.grade('q2_5')Question 6.Write a function calledpoverty_timelinethat takesthe name of a countryas itsargument. It should draw a line plot of the number of people living in poverty in that countrywith time on the horizontal axis. The line plot should have a point for each row in thepovertytable for that country. To compute the population living in poverty from a poverty percentage,multiply by the population of the countryin that year.Hint: The names within thepoverty_timelinefunction correspond to our staff solution, butyou don’t need to use them. Any way that you want to draw the plot is fine, as long as it generatesthe correct graph.Hint: For theapplymethod, if you don’t specify a particular column to apply your functionon, the whole row is used as an input to the function. Elements inside a row can be accessed using.item.Hint:This question is long. Feel free to create cells and experiment.In [10]:defpopulation_for_country_in_year(row_of_poverty_table):"""Optional: Define a function to return the populationof a country in a year using a row from the poverty table."""...defpoverty_timeline(country):"""Draw a timeline of people living in extreme poverty in a country."""geo= ...country_poverty= ......Finally, draw the timelines below to see how the world is changing. You can check your workby comparing your graphs to the ones ongapminder.org.In [11]:poverty_timeline('India')In [12]:poverty_timeline('Nigeria')In [13]:poverty_timeline('China')In [14]:poverty_timeline('United States')Although the number of people living in extreme poverty has been increasing in Nigeria andthe United States, the massive decreases in China and India have shaped the overall trend thatextreme poverty is decreasing worldwide, both in percentage and in absolute number.To learn more, watchHans Rosling in a 2015 filmabout the UN goal of eradicating extremepoverty from the world.Below,we’vealsoaddedaninteractivedropdownmenuforyoutovisualizepoverty_timelinegraphs for other countries.Note that each dropdown menu selectionmay take a few seconds to run.22
Background image
In [15]:# Just run this cellall_countries=poverty_map.column('name')_=widgets.interact(poverty_timeline, country=list(all_countries))You’re finished!Congratulations on mastering data visualization and table manipulation.Time to submit.In [ ]:_=ok.submit()23
Background image

You've reached the end of your free preview.

Want to read all 23 pages?

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern

Stuck? We have tutors online 24/7 who can help you get unstuck.
A+ icon
Ask Expert Tutors You can ask You can ask You can ask (will expire )
Answers in as fast as 15 minutes