diff --git a/Python-ifed.ipynb b/Python-ifed.ipynb
index ee9444d..ad2f1cc 100644
--- a/Python-ifed.ipynb
+++ b/Python-ifed.ipynb
@@ -62,19 +62,28 @@
"### Describe what each of the following means\n",
"\n",
"#### Production\n",
- "(Insert answer here)\n",
+ "\n",
+ "Production quality code, in simple terms, it is the code which can bear the test of time in production environment and which meets expectations in reliabilty, efficiency etc for production.\n",
+ "\n",
"#### Clean \n",
- "(Insert answer here)\n",
+ "\n",
+ "In simple words, it is readable, simple, and concise. A characteristic of production quality code that is crucial for collaboration and maintainability in software development.\n",
+ "\n",
"#### Modular\n",
- "(Insert answer here)\n",
+ "\n",
+ "Logically broken up into functions and modules. Also an important characteristic of production quality code that makes our code more organized, efficient, and reusable.\n",
+ "\n",
"#### Module\n",
- "(Insert answer here)\n",
+ "\n",
+ "A file. Modules allow code to be reused by encapsulating them into files that can be imported into other files.\n",
+ "\n",
"#### Refactoring code\n",
- "(Insert answer here)"
+ "\n",
+ "Refactoring is a way to restructure our code to improve its internal structure without changing its external functionality."
]
},
{
- "cell_type": "markdown",
+ "cell_type": "raw",
"metadata": {},
"source": [
"If you have finished writing the answers you can now commit these new changes with git using the commit message __step 1 completed__ ."
@@ -93,9 +102,214 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 4,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "
\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " Season | \n",
+ " city | \n",
+ " date | \n",
+ " team 1 | \n",
+ " team 2 | \n",
+ " toss winner | \n",
+ " toss decision | \n",
+ " result | \n",
+ " dl applied | \n",
+ " winner | \n",
+ " win by runs | \n",
+ " win by wickets | \n",
+ " player of match | \n",
+ " venue | \n",
+ " umpire 1 | \n",
+ " umpire 2 | \n",
+ "
\n",
+ " \n",
+ " | id | \n",
+ " | \n",
+ " | \n",
+ " | \n",
+ " | \n",
+ " | \n",
+ " | \n",
+ " | \n",
+ " | \n",
+ " | \n",
+ " | \n",
+ " | \n",
+ " | \n",
+ " | \n",
+ " | \n",
+ " | \n",
+ " | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | 1 | \n",
+ " IPL-2017 | \n",
+ " Hyderabad | \n",
+ " 05-04-2017 | \n",
+ " Sunrisers Hyderabad | \n",
+ " Royal Challengers Bangalore | \n",
+ " Royal Challengers Bangalore | \n",
+ " field | \n",
+ " normal | \n",
+ " 0 | \n",
+ " Sunrisers Hyderabad | \n",
+ " 35 | \n",
+ " 0 | \n",
+ " Yuvraj Singh | \n",
+ " Rajiv Gandhi International Stadium, Uppal | \n",
+ " AY Dandekar | \n",
+ " NJ Llong | \n",
+ "
\n",
+ " \n",
+ " | 2 | \n",
+ " IPL-2017 | \n",
+ " Pune | \n",
+ " 06-04-2017 | \n",
+ " Mumbai Indians | \n",
+ " Rising Pune Supergiant | \n",
+ " Rising Pune Supergiant | \n",
+ " field | \n",
+ " normal | \n",
+ " 0 | \n",
+ " Rising Pune Supergiant | \n",
+ " 0 | \n",
+ " 7 | \n",
+ " SPD Smith | \n",
+ " Maharashtra Cricket Association Stadium | \n",
+ " A Nand Kishore | \n",
+ " S Ravi | \n",
+ "
\n",
+ " \n",
+ " | 3 | \n",
+ " IPL-2017 | \n",
+ " Rajkot | \n",
+ " 07-04-2017 | \n",
+ " Gujarat Lions | \n",
+ " Kolkata Knight Riders | \n",
+ " Kolkata Knight Riders | \n",
+ " field | \n",
+ " normal | \n",
+ " 0 | \n",
+ " Kolkata Knight Riders | \n",
+ " 0 | \n",
+ " 10 | \n",
+ " CA Lynn | \n",
+ " Saurashtra Cricket Association Stadium | \n",
+ " Nitin Menon | \n",
+ " CK Nandan | \n",
+ "
\n",
+ " \n",
+ " | 4 | \n",
+ " IPL-2017 | \n",
+ " Indore | \n",
+ " 08-04-2017 | \n",
+ " Rising Pune Supergiant | \n",
+ " Kings XI Punjab | \n",
+ " Kings XI Punjab | \n",
+ " field | \n",
+ " normal | \n",
+ " 0 | \n",
+ " Kings XI Punjab | \n",
+ " 0 | \n",
+ " 6 | \n",
+ " GJ Maxwell | \n",
+ " Holkar Cricket Stadium | \n",
+ " AK Chaudhary | \n",
+ " C Shamshuddin | \n",
+ "
\n",
+ " \n",
+ " | 5 | \n",
+ " IPL-2017 | \n",
+ " Bangalore | \n",
+ " 08-04-2017 | \n",
+ " Royal Challengers Bangalore | \n",
+ " Delhi Daredevils | \n",
+ " Royal Challengers Bangalore | \n",
+ " bat | \n",
+ " normal | \n",
+ " 0 | \n",
+ " Royal Challengers Bangalore | \n",
+ " 15 | \n",
+ " 0 | \n",
+ " KM Jadhav | \n",
+ " M Chinnaswamy Stadium | \n",
+ " NaN | \n",
+ " NaN | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " Season city date team 1 \\\n",
+ "id \n",
+ "1 IPL-2017 Hyderabad 05-04-2017 Sunrisers Hyderabad \n",
+ "2 IPL-2017 Pune 06-04-2017 Mumbai Indians \n",
+ "3 IPL-2017 Rajkot 07-04-2017 Gujarat Lions \n",
+ "4 IPL-2017 Indore 08-04-2017 Rising Pune Supergiant \n",
+ "5 IPL-2017 Bangalore 08-04-2017 Royal Challengers Bangalore \n",
+ "\n",
+ " team 2 toss winner toss decision \\\n",
+ "id \n",
+ "1 Royal Challengers Bangalore Royal Challengers Bangalore field \n",
+ "2 Rising Pune Supergiant Rising Pune Supergiant field \n",
+ "3 Kolkata Knight Riders Kolkata Knight Riders field \n",
+ "4 Kings XI Punjab Kings XI Punjab field \n",
+ "5 Delhi Daredevils Royal Challengers Bangalore bat \n",
+ "\n",
+ " result dl applied winner win by runs \\\n",
+ "id \n",
+ "1 normal 0 Sunrisers Hyderabad 35 \n",
+ "2 normal 0 Rising Pune Supergiant 0 \n",
+ "3 normal 0 Kolkata Knight Riders 0 \n",
+ "4 normal 0 Kings XI Punjab 0 \n",
+ "5 normal 0 Royal Challengers Bangalore 15 \n",
+ "\n",
+ " win by wickets player of match venue \\\n",
+ "id \n",
+ "1 0 Yuvraj Singh Rajiv Gandhi International Stadium, Uppal \n",
+ "2 7 SPD Smith Maharashtra Cricket Association Stadium \n",
+ "3 10 CA Lynn Saurashtra Cricket Association Stadium \n",
+ "4 6 GJ Maxwell Holkar Cricket Stadium \n",
+ "5 0 KM Jadhav M Chinnaswamy Stadium \n",
+ "\n",
+ " umpire 1 umpire 2 \n",
+ "id \n",
+ "1 AY Dandekar NJ Llong \n",
+ "2 A Nand Kishore S Ravi \n",
+ "3 Nitin Menon CK Nandan \n",
+ "4 AK Chaudhary C Shamshuddin \n",
+ "5 NaN NaN "
+ ]
+ },
+ "execution_count": 4,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
"source": [
"import pandas as pd\n",
"df = pd.read_csv('matches.csv', sep=',')\n",
@@ -104,6 +318,34 @@
"df.head()"
]
},
+ {
+ "cell_type": "code",
+ "execution_count": 3,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Collecting pandas\n",
+ " Downloading pandas-1.2.0-cp37-cp37m-macosx_10_9_x86_64.whl (10.3 MB)\n",
+ "\u001b[K |████████████████████████████████| 10.3 MB 255 kB/s eta 0:00:01\n",
+ "\u001b[?25hRequirement already satisfied: numpy>=1.16.5 in /Users/apple/miniconda3/lib/python3.7/site-packages (from pandas) (1.18.1)\n",
+ "Requirement already satisfied: python-dateutil>=2.7.3 in /Users/apple/miniconda3/lib/python3.7/site-packages (from pandas) (2.8.1)\n",
+ "Requirement already satisfied: pytz>=2017.3 in /Users/apple/miniconda3/lib/python3.7/site-packages (from pandas) (2019.3)\n",
+ "Requirement already satisfied: six>=1.5 in /Users/apple/miniconda3/lib/python3.7/site-packages (from python-dateutil>=2.7.3->pandas) (1.14.0)\n",
+ "Installing collected packages: pandas\n",
+ "Successfully installed pandas-1.2.0\n",
+ "\u001b[33mWARNING: You are using pip version 20.2.4; however, version 20.3.3 is available.\n",
+ "You should consider upgrading via the '/Users/apple/miniconda3/bin/python -m pip install --upgrade pip' command.\u001b[0m\n",
+ "Note: you may need to restart the kernel to use updated packages.\n"
+ ]
+ }
+ ],
+ "source": [
+ "pip install pandas"
+ ]
+ },
{
"cell_type": "markdown",
"metadata": {},
@@ -113,9 +355,214 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 5,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " Season | \n",
+ " city | \n",
+ " date | \n",
+ " team_1 | \n",
+ " team_2 | \n",
+ " toss_winner | \n",
+ " toss decision | \n",
+ " result | \n",
+ " dl_applied | \n",
+ " winner | \n",
+ " win_by_runs | \n",
+ " win_by_wickets | \n",
+ " player_of_match | \n",
+ " venue | \n",
+ " umpire_1 | \n",
+ " umpire_2 | \n",
+ "
\n",
+ " \n",
+ " | id | \n",
+ " | \n",
+ " | \n",
+ " | \n",
+ " | \n",
+ " | \n",
+ " | \n",
+ " | \n",
+ " | \n",
+ " | \n",
+ " | \n",
+ " | \n",
+ " | \n",
+ " | \n",
+ " | \n",
+ " | \n",
+ " | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | 1 | \n",
+ " IPL-2017 | \n",
+ " Hyderabad | \n",
+ " 05-04-2017 | \n",
+ " Sunrisers Hyderabad | \n",
+ " Royal Challengers Bangalore | \n",
+ " Royal Challengers Bangalore | \n",
+ " field | \n",
+ " normal | \n",
+ " 0 | \n",
+ " Sunrisers Hyderabad | \n",
+ " 35 | \n",
+ " 0 | \n",
+ " Yuvraj Singh | \n",
+ " Rajiv Gandhi International Stadium, Uppal | \n",
+ " AY Dandekar | \n",
+ " NJ Llong | \n",
+ "
\n",
+ " \n",
+ " | 2 | \n",
+ " IPL-2017 | \n",
+ " Pune | \n",
+ " 06-04-2017 | \n",
+ " Mumbai Indians | \n",
+ " Rising Pune Supergiant | \n",
+ " Rising Pune Supergiant | \n",
+ " field | \n",
+ " normal | \n",
+ " 0 | \n",
+ " Rising Pune Supergiant | \n",
+ " 0 | \n",
+ " 7 | \n",
+ " SPD Smith | \n",
+ " Maharashtra Cricket Association Stadium | \n",
+ " A Nand Kishore | \n",
+ " S Ravi | \n",
+ "
\n",
+ " \n",
+ " | 3 | \n",
+ " IPL-2017 | \n",
+ " Rajkot | \n",
+ " 07-04-2017 | \n",
+ " Gujarat Lions | \n",
+ " Kolkata Knight Riders | \n",
+ " Kolkata Knight Riders | \n",
+ " field | \n",
+ " normal | \n",
+ " 0 | \n",
+ " Kolkata Knight Riders | \n",
+ " 0 | \n",
+ " 10 | \n",
+ " CA Lynn | \n",
+ " Saurashtra Cricket Association Stadium | \n",
+ " Nitin Menon | \n",
+ " CK Nandan | \n",
+ "
\n",
+ " \n",
+ " | 4 | \n",
+ " IPL-2017 | \n",
+ " Indore | \n",
+ " 08-04-2017 | \n",
+ " Rising Pune Supergiant | \n",
+ " Kings XI Punjab | \n",
+ " Kings XI Punjab | \n",
+ " field | \n",
+ " normal | \n",
+ " 0 | \n",
+ " Kings XI Punjab | \n",
+ " 0 | \n",
+ " 6 | \n",
+ " GJ Maxwell | \n",
+ " Holkar Cricket Stadium | \n",
+ " AK Chaudhary | \n",
+ " C Shamshuddin | \n",
+ "
\n",
+ " \n",
+ " | 5 | \n",
+ " IPL-2017 | \n",
+ " Bangalore | \n",
+ " 08-04-2017 | \n",
+ " Royal Challengers Bangalore | \n",
+ " Delhi Daredevils | \n",
+ " Royal Challengers Bangalore | \n",
+ " bat | \n",
+ " normal | \n",
+ " 0 | \n",
+ " Royal Challengers Bangalore | \n",
+ " 15 | \n",
+ " 0 | \n",
+ " KM Jadhav | \n",
+ " M Chinnaswamy Stadium | \n",
+ " NaN | \n",
+ " NaN | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " Season city date team_1 \\\n",
+ "id \n",
+ "1 IPL-2017 Hyderabad 05-04-2017 Sunrisers Hyderabad \n",
+ "2 IPL-2017 Pune 06-04-2017 Mumbai Indians \n",
+ "3 IPL-2017 Rajkot 07-04-2017 Gujarat Lions \n",
+ "4 IPL-2017 Indore 08-04-2017 Rising Pune Supergiant \n",
+ "5 IPL-2017 Bangalore 08-04-2017 Royal Challengers Bangalore \n",
+ "\n",
+ " team_2 toss_winner toss decision \\\n",
+ "id \n",
+ "1 Royal Challengers Bangalore Royal Challengers Bangalore field \n",
+ "2 Rising Pune Supergiant Rising Pune Supergiant field \n",
+ "3 Kolkata Knight Riders Kolkata Knight Riders field \n",
+ "4 Kings XI Punjab Kings XI Punjab field \n",
+ "5 Delhi Daredevils Royal Challengers Bangalore bat \n",
+ "\n",
+ " result dl_applied winner win_by_runs \\\n",
+ "id \n",
+ "1 normal 0 Sunrisers Hyderabad 35 \n",
+ "2 normal 0 Rising Pune Supergiant 0 \n",
+ "3 normal 0 Kolkata Knight Riders 0 \n",
+ "4 normal 0 Kings XI Punjab 0 \n",
+ "5 normal 0 Royal Challengers Bangalore 15 \n",
+ "\n",
+ " win_by_wickets player_of_match venue \\\n",
+ "id \n",
+ "1 0 Yuvraj Singh Rajiv Gandhi International Stadium, Uppal \n",
+ "2 7 SPD Smith Maharashtra Cricket Association Stadium \n",
+ "3 10 CA Lynn Saurashtra Cricket Association Stadium \n",
+ "4 6 GJ Maxwell Holkar Cricket Stadium \n",
+ "5 0 KM Jadhav M Chinnaswamy Stadium \n",
+ "\n",
+ " umpire_1 umpire_2 \n",
+ "id \n",
+ "1 AY Dandekar NJ Llong \n",
+ "2 A Nand Kishore S Ravi \n",
+ "3 Nitin Menon CK Nandan \n",
+ "4 AK Chaudhary C Shamshuddin \n",
+ "5 NaN NaN "
+ ]
+ },
+ "execution_count": 5,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
"source": [
"new_df = df.rename(columns={'team 1': 'team_1',\n",
" 'team 2': 'team_2',\n",
@@ -139,9 +586,214 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 6,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " Season | \n",
+ " city | \n",
+ " date | \n",
+ " team_1 | \n",
+ " team 2 | \n",
+ " toss_winner | \n",
+ " toss_decision | \n",
+ " result | \n",
+ " dl_applied | \n",
+ " winner | \n",
+ " win_by_runs | \n",
+ " win by wickets | \n",
+ " player of match | \n",
+ " venue | \n",
+ " umpire 1 | \n",
+ " umpire 2 | \n",
+ "
\n",
+ " \n",
+ " | id | \n",
+ " | \n",
+ " | \n",
+ " | \n",
+ " | \n",
+ " | \n",
+ " | \n",
+ " | \n",
+ " | \n",
+ " | \n",
+ " | \n",
+ " | \n",
+ " | \n",
+ " | \n",
+ " | \n",
+ " | \n",
+ " | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | 1 | \n",
+ " IPL-2017 | \n",
+ " Hyderabad | \n",
+ " 05-04-2017 | \n",
+ " Sunrisers Hyderabad | \n",
+ " Royal Challengers Bangalore | \n",
+ " Royal Challengers Bangalore | \n",
+ " field | \n",
+ " normal | \n",
+ " 0 | \n",
+ " Sunrisers Hyderabad | \n",
+ " 35 | \n",
+ " 0 | \n",
+ " Yuvraj Singh | \n",
+ " Rajiv Gandhi International Stadium, Uppal | \n",
+ " AY Dandekar | \n",
+ " NJ Llong | \n",
+ "
\n",
+ " \n",
+ " | 2 | \n",
+ " IPL-2017 | \n",
+ " Pune | \n",
+ " 06-04-2017 | \n",
+ " Mumbai Indians | \n",
+ " Rising Pune Supergiant | \n",
+ " Rising Pune Supergiant | \n",
+ " field | \n",
+ " normal | \n",
+ " 0 | \n",
+ " Rising Pune Supergiant | \n",
+ " 0 | \n",
+ " 7 | \n",
+ " SPD Smith | \n",
+ " Maharashtra Cricket Association Stadium | \n",
+ " A Nand Kishore | \n",
+ " S Ravi | \n",
+ "
\n",
+ " \n",
+ " | 3 | \n",
+ " IPL-2017 | \n",
+ " Rajkot | \n",
+ " 07-04-2017 | \n",
+ " Gujarat Lions | \n",
+ " Kolkata Knight Riders | \n",
+ " Kolkata Knight Riders | \n",
+ " field | \n",
+ " normal | \n",
+ " 0 | \n",
+ " Kolkata Knight Riders | \n",
+ " 0 | \n",
+ " 10 | \n",
+ " CA Lynn | \n",
+ " Saurashtra Cricket Association Stadium | \n",
+ " Nitin Menon | \n",
+ " CK Nandan | \n",
+ "
\n",
+ " \n",
+ " | 4 | \n",
+ " IPL-2017 | \n",
+ " Indore | \n",
+ " 08-04-2017 | \n",
+ " Rising Pune Supergiant | \n",
+ " Kings XI Punjab | \n",
+ " Kings XI Punjab | \n",
+ " field | \n",
+ " normal | \n",
+ " 0 | \n",
+ " Kings XI Punjab | \n",
+ " 0 | \n",
+ " 6 | \n",
+ " GJ Maxwell | \n",
+ " Holkar Cricket Stadium | \n",
+ " AK Chaudhary | \n",
+ " C Shamshuddin | \n",
+ "
\n",
+ " \n",
+ " | 5 | \n",
+ " IPL-2017 | \n",
+ " Bangalore | \n",
+ " 08-04-2017 | \n",
+ " Royal Challengers Bangalore | \n",
+ " Delhi Daredevils | \n",
+ " Royal Challengers Bangalore | \n",
+ " bat | \n",
+ " normal | \n",
+ " 0 | \n",
+ " Royal Challengers Bangalore | \n",
+ " 15 | \n",
+ " 0 | \n",
+ " KM Jadhav | \n",
+ " M Chinnaswamy Stadium | \n",
+ " NaN | \n",
+ " NaN | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " Season city date team_1 \\\n",
+ "id \n",
+ "1 IPL-2017 Hyderabad 05-04-2017 Sunrisers Hyderabad \n",
+ "2 IPL-2017 Pune 06-04-2017 Mumbai Indians \n",
+ "3 IPL-2017 Rajkot 07-04-2017 Gujarat Lions \n",
+ "4 IPL-2017 Indore 08-04-2017 Rising Pune Supergiant \n",
+ "5 IPL-2017 Bangalore 08-04-2017 Royal Challengers Bangalore \n",
+ "\n",
+ " team 2 toss_winner toss_decision \\\n",
+ "id \n",
+ "1 Royal Challengers Bangalore Royal Challengers Bangalore field \n",
+ "2 Rising Pune Supergiant Rising Pune Supergiant field \n",
+ "3 Kolkata Knight Riders Kolkata Knight Riders field \n",
+ "4 Kings XI Punjab Kings XI Punjab field \n",
+ "5 Delhi Daredevils Royal Challengers Bangalore bat \n",
+ "\n",
+ " result dl_applied winner win_by_runs \\\n",
+ "id \n",
+ "1 normal 0 Sunrisers Hyderabad 35 \n",
+ "2 normal 0 Rising Pune Supergiant 0 \n",
+ "3 normal 0 Kolkata Knight Riders 0 \n",
+ "4 normal 0 Kings XI Punjab 0 \n",
+ "5 normal 0 Royal Challengers Bangalore 15 \n",
+ "\n",
+ " win by wickets player of match venue \\\n",
+ "id \n",
+ "1 0 Yuvraj Singh Rajiv Gandhi International Stadium, Uppal \n",
+ "2 7 SPD Smith Maharashtra Cricket Association Stadium \n",
+ "3 10 CA Lynn Saurashtra Cricket Association Stadium \n",
+ "4 6 GJ Maxwell Holkar Cricket Stadium \n",
+ "5 0 KM Jadhav M Chinnaswamy Stadium \n",
+ "\n",
+ " umpire 1 umpire 2 \n",
+ "id \n",
+ "1 AY Dandekar NJ Llong \n",
+ "2 A Nand Kishore S Ravi \n",
+ "3 Nitin Menon CK Nandan \n",
+ "4 AK Chaudhary C Shamshuddin \n",
+ "5 NaN NaN "
+ ]
+ },
+ "execution_count": 6,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
"source": [
"labels = list(df.columns)\n",
"labels[0] = labels[0].replace(' ', '_')\n",
@@ -167,15 +819,224 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 9,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " Season | \n",
+ " city | \n",
+ " date | \n",
+ " team_1 | \n",
+ " team_2 | \n",
+ " toss_winner | \n",
+ " toss_decision | \n",
+ " result | \n",
+ " dl_applied | \n",
+ " winner | \n",
+ " win_by_runs | \n",
+ " win by wickets | \n",
+ " player of match | \n",
+ " venue | \n",
+ " umpire 1 | \n",
+ " umpire 2 | \n",
+ "
\n",
+ " \n",
+ " | id | \n",
+ " | \n",
+ " | \n",
+ " | \n",
+ " | \n",
+ " | \n",
+ " | \n",
+ " | \n",
+ " | \n",
+ " | \n",
+ " | \n",
+ " | \n",
+ " | \n",
+ " | \n",
+ " | \n",
+ " | \n",
+ " | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | 1 | \n",
+ " IPL-2017 | \n",
+ " Hyderabad | \n",
+ " 05-04-2017 | \n",
+ " Sunrisers Hyderabad | \n",
+ " Royal Challengers Bangalore | \n",
+ " Royal Challengers Bangalore | \n",
+ " field | \n",
+ " normal | \n",
+ " 0 | \n",
+ " Sunrisers Hyderabad | \n",
+ " 35 | \n",
+ " 0 | \n",
+ " Yuvraj Singh | \n",
+ " Rajiv Gandhi International Stadium, Uppal | \n",
+ " AY Dandekar | \n",
+ " NJ Llong | \n",
+ "
\n",
+ " \n",
+ " | 2 | \n",
+ " IPL-2017 | \n",
+ " Pune | \n",
+ " 06-04-2017 | \n",
+ " Mumbai Indians | \n",
+ " Rising Pune Supergiant | \n",
+ " Rising Pune Supergiant | \n",
+ " field | \n",
+ " normal | \n",
+ " 0 | \n",
+ " Rising Pune Supergiant | \n",
+ " 0 | \n",
+ " 7 | \n",
+ " SPD Smith | \n",
+ " Maharashtra Cricket Association Stadium | \n",
+ " A Nand Kishore | \n",
+ " S Ravi | \n",
+ "
\n",
+ " \n",
+ " | 3 | \n",
+ " IPL-2017 | \n",
+ " Rajkot | \n",
+ " 07-04-2017 | \n",
+ " Gujarat Lions | \n",
+ " Kolkata Knight Riders | \n",
+ " Kolkata Knight Riders | \n",
+ " field | \n",
+ " normal | \n",
+ " 0 | \n",
+ " Kolkata Knight Riders | \n",
+ " 0 | \n",
+ " 10 | \n",
+ " CA Lynn | \n",
+ " Saurashtra Cricket Association Stadium | \n",
+ " Nitin Menon | \n",
+ " CK Nandan | \n",
+ "
\n",
+ " \n",
+ " | 4 | \n",
+ " IPL-2017 | \n",
+ " Indore | \n",
+ " 08-04-2017 | \n",
+ " Rising Pune Supergiant | \n",
+ " Kings XI Punjab | \n",
+ " Kings XI Punjab | \n",
+ " field | \n",
+ " normal | \n",
+ " 0 | \n",
+ " Kings XI Punjab | \n",
+ " 0 | \n",
+ " 6 | \n",
+ " GJ Maxwell | \n",
+ " Holkar Cricket Stadium | \n",
+ " AK Chaudhary | \n",
+ " C Shamshuddin | \n",
+ "
\n",
+ " \n",
+ " | 5 | \n",
+ " IPL-2017 | \n",
+ " Bangalore | \n",
+ " 08-04-2017 | \n",
+ " Royal Challengers Bangalore | \n",
+ " Delhi Daredevils | \n",
+ " Royal Challengers Bangalore | \n",
+ " bat | \n",
+ " normal | \n",
+ " 0 | \n",
+ " Royal Challengers Bangalore | \n",
+ " 15 | \n",
+ " 0 | \n",
+ " KM Jadhav | \n",
+ " M Chinnaswamy Stadium | \n",
+ " NaN | \n",
+ " NaN | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " Season city date team_1 \\\n",
+ "id \n",
+ "1 IPL-2017 Hyderabad 05-04-2017 Sunrisers Hyderabad \n",
+ "2 IPL-2017 Pune 06-04-2017 Mumbai Indians \n",
+ "3 IPL-2017 Rajkot 07-04-2017 Gujarat Lions \n",
+ "4 IPL-2017 Indore 08-04-2017 Rising Pune Supergiant \n",
+ "5 IPL-2017 Bangalore 08-04-2017 Royal Challengers Bangalore \n",
+ "\n",
+ " team_2 toss_winner toss_decision \\\n",
+ "id \n",
+ "1 Royal Challengers Bangalore Royal Challengers Bangalore field \n",
+ "2 Rising Pune Supergiant Rising Pune Supergiant field \n",
+ "3 Kolkata Knight Riders Kolkata Knight Riders field \n",
+ "4 Kings XI Punjab Kings XI Punjab field \n",
+ "5 Delhi Daredevils Royal Challengers Bangalore bat \n",
+ "\n",
+ " result dl_applied winner win_by_runs \\\n",
+ "id \n",
+ "1 normal 0 Sunrisers Hyderabad 35 \n",
+ "2 normal 0 Rising Pune Supergiant 0 \n",
+ "3 normal 0 Kolkata Knight Riders 0 \n",
+ "4 normal 0 Kings XI Punjab 0 \n",
+ "5 normal 0 Royal Challengers Bangalore 15 \n",
+ "\n",
+ " win by wickets player of match venue \\\n",
+ "id \n",
+ "1 0 Yuvraj Singh Rajiv Gandhi International Stadium, Uppal \n",
+ "2 7 SPD Smith Maharashtra Cricket Association Stadium \n",
+ "3 10 CA Lynn Saurashtra Cricket Association Stadium \n",
+ "4 6 GJ Maxwell Holkar Cricket Stadium \n",
+ "5 0 KM Jadhav M Chinnaswamy Stadium \n",
+ "\n",
+ " umpire 1 umpire 2 \n",
+ "id \n",
+ "1 AY Dandekar NJ Llong \n",
+ "2 A Nand Kishore S Ravi \n",
+ "3 Nitin Menon CK Nandan \n",
+ "4 AK Chaudhary C Shamshuddin \n",
+ "5 NaN NaN "
+ ]
+ },
+ "execution_count": 9,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
"source": [
- "# Insert your solution here"
+ "labels=list(df.columns)\n",
+ "for val in range(0,11):\n",
+ " labels[val]=labels[val].replace(' ','_')\n",
+ "df.columns=labels\n",
+ "df.head()"
]
},
{
- "cell_type": "markdown",
+ "cell_type": "raw",
"metadata": {},
"source": [
"Once you are done till here make a new commit with message __step 2 complete__."
@@ -208,7 +1069,7 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 10,
"metadata": {},
"outputs": [],
"source": [
@@ -219,7 +1080,7 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 11,
"metadata": {},
"outputs": [],
"source": [
@@ -233,9 +1094,18 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 12,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "96\n",
+ "Duration: 16.211009979248047 seconds\n"
+ ]
+ }
+ ],
"source": [
"start = time.time()\n",
"verified_elements = []\n",
@@ -257,11 +1127,21 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 13,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "96\n",
+ "Duration: 0.05957913398742676 seconds\n"
+ ]
+ }
+ ],
"source": [
- "# Insert answer here\n",
+ "start = time.time()\n",
+ "verified_elements= np.intersect1d(subset_elements,all_elements)\n",
"\n",
"print(len(verified_elements))\n",
"print('Duration: {} seconds'.format(time.time() - start))"
@@ -276,11 +1156,21 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 14,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "96\n",
+ "Duration: 0.010120153427124023 seconds\n"
+ ]
+ }
+ ],
"source": [
- "# Insert answer here\n",
+ "start = time.time()\n",
+ "verified_elements=set(all_elements).intersection(subset_elements)\n",
"\n",
"print(len(verified_elements))\n",
"print('Duration: {} seconds'.format(time.time() - start))"
@@ -386,11 +1276,24 @@
},
{
"cell_type": "code",
- "execution_count": 1,
+ "execution_count": 26,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "'fighting'"
+ ]
+ },
+ "execution_count": 26,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
"source": [
- "# Insert your code here"
+ "import requests\n",
+ "pokemon_details = requests.get(\"https://pokeapi.co/api/v2/pokemon/machamp\").json()\n",
+ "pokemon_details['types'][0]['type']['name']"
]
},
{
@@ -404,11 +1307,28 @@
},
{
"cell_type": "code",
- "execution_count": 2,
+ "execution_count": 40,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "flying\n",
+ "psychic\n",
+ "fairy\n",
+ "rock\n",
+ "bug\n",
+ "dark\n"
+ ]
+ }
+ ],
"source": [
- "# Insert your code here"
+ "damage_from_types = requests.get(pokemon_details['types'][0]['type']['url']).json()\n",
+ "for damage_type in damage_from_types['damage_relations'].keys():\n",
+ " if(damage_type in ['double_damage_from', 'half_damage_from']):\n",
+ " for pokemon_type in damage_from_types['damage_relations'][damage_type]:\n",
+ " print(pokemon_type['name'])"
]
},
{
@@ -420,11 +1340,47 @@
},
{
"cell_type": "code",
- "execution_count": 3,
+ "execution_count": 44,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Double damage from type: flying\n",
+ "charizard\n",
+ "butterfree\n",
+ "pidgey\n",
+ "pidgeotto\n",
+ "pidgeot\n",
+ "Double damage from type: psychic\n",
+ "abra\n",
+ "kadabra\n",
+ "alakazam\n",
+ "slowpoke\n",
+ "slowbro\n",
+ "Double damage from type: fairy\n",
+ "clefairy\n",
+ "clefable\n",
+ "jigglypuff\n",
+ "wigglytuff\n",
+ "mr-mime\n"
+ ]
+ }
+ ],
"source": [
- "# Insert your code here"
+ "double_damage_from_types = damage_from_types['damage_relations']['double_damage_from']\n",
+ "for pokemon_type in double_damage_from_types:\n",
+ " print(\"Double damage from type: \", pokemon_type['name'])\n",
+ " url = pokemon_type['url']\n",
+ " type_details = requests.get(url).json()\n",
+ " pokemons = type_details['pokemon']\n",
+ " if(len(pokemons) > 5):\n",
+ " for i in range(0,5):\n",
+ " print(pokemons[i]['pokemon']['name'])\n",
+ " else:\n",
+ " for i in range(0, len(pokemons)):\n",
+ " print(pokemons[i]['pokemon']['name'])"
]
},
{
@@ -515,9 +1471,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
- "version": "3.6.9"
+ "version": "3.7.7"
}
},
"nbformat": 4,
"nbformat_minor": 4
-}
\ No newline at end of file
+}
diff --git a/ability.py b/ability.py
new file mode 100644
index 0000000..dcf50d6
--- /dev/null
+++ b/ability.py
@@ -0,0 +1,9 @@
+import requests
+
+
+def ability(pokemon_name):
+ pokemon_details = requests.get(f"https://pokeapi.co/api/v2/pokemon/{pokemon_name}").json()
+ abilities = []
+ for pokemon_ability in pokemon_details['abilities']:
+ abilities.append(pokemon_ability['ability']['name'])
+ return abilities
diff --git a/nearest_square.py b/nearest_square.py
new file mode 100644
index 0000000..01eb986
--- /dev/null
+++ b/nearest_square.py
@@ -0,0 +1,5 @@
+def nearest_square(limit):
+ i = 0
+ while (i+1)**2 <= limit:
+ i += 1
+ return i ** 2
diff --git a/step_4.py b/step_4.py
new file mode 100644
index 0000000..4a8da52
--- /dev/null
+++ b/step_4.py
@@ -0,0 +1,85 @@
+import time
+import pandas as pd
+import numpy as np
+
+
+def f1(subset_elements,all_elements):
+ """
+ Uses for loop to get common elements from the given two lists.
+
+ Parameters:
+ subset_elements (list):
+ contains list of elements of subset_elemets.txt
+ all_elements (list):
+ contains list of elements of all_elements.txt
+
+ """
+
+ start = time.time()
+ verified_elements = []
+
+ for element in subset_elements:
+ if element in all_elements:
+ verified_elements.append(element)
+
+ print(len(verified_elements))
+ print('Duration: {} seconds'.format(time.time() - start))
+
+
+def f2(subset_elements,all_elements):
+ """
+ Uses numpy.intersect1d() function to get common elements from the given two lists.
+
+ Parameters:
+ subset_elements (list):
+ contains list of elements of subset_elemets.txt
+ all_elements (list):
+ contains list of elements of all_elements.txt
+
+ """
+
+ start = time.time()
+ verified_elements = np.intersect1d(subset_elements, all_elements)
+
+ print(len(verified_elements))
+ print('Duration: {} seconds'.format(time.time() - start))
+
+
+def f3(subset_elements,all_elements):
+ """
+ Uses set().intersecton() data structure function to get common elements from the given two lists.
+
+ Parameters:
+ subset_elements (list):
+ contains list of elements of subset_elemets.txt
+ all_elements (list):
+ contains list of elements of all_elements.txt
+
+ """
+
+ start = time.time()
+ verified_elements = set(all_elements).intersection(subset_elements)
+
+ print(len(verified_elements))
+ print('Duration: {} seconds'.format(time.time() - start))
+
+
+def main():
+ """
+ Reads data from subset_elemets.txt and all_elements.txt and stores in subset_elements and all_elements resp.
+
+ """
+
+ with open('subset_elemets.txt') as f:
+ subset_elements = f.read().split('\n')
+
+ with open('all_elements.txt') as f:
+ all_elements = f.read().split('\n')
+
+ f1(subset_elements,all_elements)
+ f2(subset_elements,all_elements)
+ f3(subset_elements,all_elements)
+
+
+if __name__ == "__main__":
+ main()