0% found this document useful (0 votes)
65 views2 pages

Python Data Science Toolbox: Completion 1.3 (D)

The document provides instructions and examples for completing data science exercises in a Jupyter notebook using various Python tools and datasets. The exercises include: 1) Creating a NumPy array from a list of baseball player data and converting units 2) Plotting yearly CO2 emissions data for Thailand 3) Visualizing the relationship between child mortality, GDP per capita, and population for several Southeast Asian countries 4) Working with datasets on cars ownership and weather data from Austin, Texas

Uploaded by

Emely Gonzaga
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
65 views2 pages

Python Data Science Toolbox: Completion 1.3 (D)

The document provides instructions and examples for completing data science exercises in a Jupyter notebook using various Python tools and datasets. The exercises include: 1) Creating a NumPy array from a list of baseball player data and converting units 2) Plotting yearly CO2 emissions data for Thailand 3) Visualizing the relationship between child mortality, GDP per capita, and population for several Southeast Asian countries 4) Working with datasets on cars ownership and weather data from Austin, Texas

Uploaded by

Emely Gonzaga
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

DS100-1

Completion 1.3 (D)


APPLIED DATA SCIENCE
PYTHON DATA SCIENCE TOOLBOX

Name:

Page 1 of 2

Write codes in Jupyter notebook as required by the problems. Copy both code and output as screen grab or screen shot and paste
them here.

1 Create a list of lists. The individual lists should contain, in the correct order, the weight (in pounds), the height (in inches)
and the age of the baseball players.

Weights: 180 215 210 210 188 176 209 200 231 180 188 180 185 160 180 185 189 185 219 230
Heights: 74 74 72 72 73 69 69 71 76 71 73 73 74 74 69 70 73 75 78 79
Ages: 23 35 31 36 24 30 31 36 31 28 24 27 24 27 28 35 28 23 23 26

Convert the list of lists into a NumPy array named np_baseball. Using NumPy functionality, convert the unit of weight
to kg and the height to m. Print the resulting array.
Code and Output

2 Refer to the code in #1. Write a code that determines the age of the 7th player. The output should be in the following form:
The 7th player is <age> years old.
Code and Output

3 Refer to the code in #1. Print out the ages of the young players (those who are 26 years old and below).
Code and Output

4 Create a line plot showing the yearly CO2 emissions per person in Thailand. Make sure to add labels and a title to your plot.

CO2 Emissions per country per year (tons per person)


country 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014
Brunei 13.9 13.7 13.1 22.5 24 20.5 21.1 24.6 24.2 19.2 22.1
Cambodia 0.187 0.209 0.223 0.253 0.281 0.33 0.35 0.358 0.369 0.373 0.438
Indonesia 1.51 1.51 1.5 1.61 1.76 1.87 1.77 2.46 2.56 1.95 1.82
Lao 0.246 0.244 0.265 0.153 0.156 0.204 0.262 0.256 0.265 0.243 0.297
Malaysia 6.51 6.8 6.41 6.94 7.53 7.2 7.77 7.7 7.5 7.96 8.03
Myanmar 0.259 0.239 0.263 0.262 0.198 0.205 0.25 0.283 0.217 0.25 0.417
Philippines 0.875 0.867 0.771 0.808 0.869 0.841 0.905 0.897 0.942 0.996 1.06
Singapore 6.52 6.76 6.68 4.21 7.45 11.3 11 8.74 6.9 10.4 10.3
Thailand 3.74 3.78 3.83 3.81 3.79 4 4.19 4.12 4.37 4.4 4.62
Vietnam 1.08 1.16 1.21 1.22 1.36 1.47 1.61 1.7 1.57 1.61 1.8

Code and Output

Page 1 of 2
5 Based on the plot, in approximately what year is there more than
four billion human beings on this planet?

6 Visualize Child Mortality as a function of GDP per Capita for the following South East Asia countries. Use Population as an
additional argument. Do not forget to label the axes and to add a title.

Fertility Life Expectancy Population Child Mortality GDP Per Capita


Philippines 3.151 68.207 93.2 31.9 5614
Thailand 1.443 73.852 69.1 14.5 12822
Singapore 1.261 81.788 50.9 2.8 72056
Vietnam 1.82 75.49 87.8 24.8 4486
Indonesia 2.434 70.185 239.9 33.1 8498
Malaysia 2.001 74.479 48.0 8.3 20398

Code and Output

7 Import cars.csv. Use the country abbreviations as index. Print the first four lines.
Code and Output

8 Refer to the cars dataset. Create a code that prints out the country name and number of cars per capita for India, Russia
and Morocco.
Code and Output

9 Refer to the cars dataset. Create a code that prints out the observations for the countries with many cars (cars per capita
greater than 400).
Code and Output

10 Import weather_data_austin_2010.csv. Make sure to use a DateTimeIndex. Extract the Temperature


column and save the result to temp0. Extract data from temp0 for a single hour – the hour from 9 pm to 10 pm on
January 2, 2010. Assign the data to temp1. Print temp0 and temp1.
Code and Output

Page 2 of 2

You might also like