Answer To: ASSESSMENT GUIDE Unit: ITEC102 Python fundamentals for data science, Semester 2, 2021 Assessment...
Darshan answered on Oct 12 2021
{
"cells": [
{
"cell_type": "code",
"execution_count": 2,
"id": "e1823cad",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"ITEC102 Python fundamentals for data science\n",
"\n",
"\n"
]
}
],
"source": [
"#program start\n",
"print(\"ITEC102 Python fundamentals for data science\")\n",
"print(\"\")\n",
"print(\"\")"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "a131cac6",
"metadata": {},
"outputs": [],
"source": [
"#import pandas module\n",
"import pandas as pd"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "7de178dc",
"metadata": {},
"outputs": [],
"source": [
"#import numpy module\n",
"import numpy as np\t"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "03f47f91",
"metadata": {},
"outputs": [],
"source": [
"#read csv file\n",
"deaths_df = pd.read_csv('https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_deaths_global.csv')\t\n",
"df = pd.DataFrame(deaths_df)\t"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "2e2a176b",
"metadata": {},
"outputs": [],
"source": [
"#find column\n",
"col = len(df.columns)\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\n",
"#print(\"Column\")\n",
"#print(col)\n",
"\n",
"#find rows\t\n",
"row = len(df.index)\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\n",
"#print(\"Rows\")\n",
"#print(row)"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "aa12e62b",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Display first 5 rows of the loaded data\n",
" Province/State Country/Region Lat Long 1/22/20 1/23/20 \\\n",
"0 NaN Afghanistan 33.93911 67.709953 0 0 \n",
"1 NaN Albania 41.15330 20.168300 0 0 \n",
"2 NaN Algeria 28.03390 1.659600 0 0 \n",
"3 NaN Andorra 42.50630 1.521800 0 0 \n",
"4 NaN Angola -11.20270 17.873900 0 0 \n",
"\n",
" 1/24/20 1/25/20 1/26/20 1/27/20 ... 10/1/21 10/2/21 10/3/21 \\\n",
"0 0 0 0 0 ... 7206 7206 7206 \n",
"1 0 0 0 0 ... 2705 2710 2713 \n",
"2 0 0 0 0 ... 5815 5819 5822 \n",
"3 0 0 0 0 ... 130 130 130 \n",
"4 0 0 0 0 ... 1567 1574 1577 \n",
"\n",
" 10/4/21 10/5/21 10/6/21 10/7/21 10/8/21 10/9/21 10/10/21 \n",
"0 7212 7214 7220 7221 7221 7221 7225 \n",
"1 2713 2725 2734 2746 2753 2759 2768 \n",
"2 5826 5831 5838 5843 5846 5850 5853 \n",
"3 130 130 130 130 130 130 130 \n",
"4 1577 1587 1598 1603 1613 1618 1622 \n",
"\n",
"[5 rows x 632 columns]\n"
]
}
],
"source": [
"#Display first 5 rows of the loaded data\n",
"print(\"Display first 5 rows of the loaded data\")\n",
"df_first_5 = deaths_df.head(5)\n",
"print(df_first_5)\n"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "b193420e",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Display short summary of 5 rows of the loaded data\n",
"\n",
"RangeIndex: 5 entries, 0 to 4\n",
"Columns: 632 entries, Province/State to 10/10/21\n",
"dtypes: float64(2), int64(628), object(2)\n",
"memory usage: 24.8+ KB\n",
"None\n"
]
}
],
"source": [
"#short summary about the data\n",
"print(\"Display short summary of 5 rows of the loaded data\")\n",
"df_info = df_first_5.info()\n",
"print(df_info)"
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "eb0a4e5f",
"metadata": {},
"outputs": [],
"source": [
"#function to get daily increasement of confirmed cases\n",
"def count_case():\n",
"\ttoday = df.iloc[:, col-1].sum()\n",
"\tyesterday = df.iloc[:, col-2].sum()\n",
"\tprint(\"Daily increasement of confirmed cases :\")\n",
"\tprint((today-yesterday))"
]
},
{
"cell_type": "code",
"execution_count": 10,
"id": "336cd4bf",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Daily increasement of confirmed cases :\n",
"4480\n"
]
}
],
"source": [
"#call function to get daily count\n",
"count_case()"
]
},
{
"cell_type": "code",
"execution_count": 11,
"id": "a467b339",
"metadata": {},
"outputs": [],
"source": [
"#import matplotlib module\n",
"import matplotlib.pyplot as plt"
]
},
{
"cell_type": "code",
"execution_count": 12,
"id": "0e703a0c",
"metadata": {
"scrolled": true
},
"outputs": [
{
"data": {
"image/png":...