0% found this document useful (0 votes)
16 views5 pages

DS100

The document provides examples of Python codes for data science tasks. It includes codes to create lists and NumPy arrays from data, determine values from the arrays, create plots of CO2 emissions and population data, and analyze a dataset on cars and countries.

Uploaded by

brixter icmat
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)
16 views5 pages

DS100

The document provides examples of Python codes for data science tasks. It includes codes to create lists and NumPy arrays from data, determine values from the arrays, create plots of CO2 emissions and population data, and analyze a dataset on cars and countries.

Uploaded by

brixter icmat
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/ 5

Worksheet 1.

3 DS100-1
APPLIED DATA SCIENCE
PYTHON DATA SCIENCE TOOLBOX
Name: BRIXTER JAMES Q ICMAT

Page 1 of 5

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 3rd player. The output should be in the following
form:
The 3rd player is <age> years old.
Code and Output

Page 1 of 5
3 Refer to the code in #1. Print out the ages of the old players (30 years and above).
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 2 of 5
Page 3 of 5
5 Based on the plot, in approximately what year will the population
reach ten billion?

2060

6 Visualize Population as a function of GDP per Capita for the following South East Asia countries. Use Child Mortality 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 three lines. Create a code that prints out the
country name and the number of cars per capita for Japan, India and Russia.
Page 4 of 5
Code and Output

8 Refer to the cars dataset. Create a code that prints out the observations for the countries that drive on the left side of the
road.
Code and Output

Page 5 of 5

You might also like