From d1bd5f81bf1462b7d8aeb51345b10563eeeeb95d Mon Sep 17 00:00:00 2001 From: aksmungekar Date: Mon, 17 Sep 2018 16:39:01 +0000 Subject: [PATCH 1/7] Done --- q01_read_csv_data_to_df/build.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/q01_read_csv_data_to_df/build.py b/q01_read_csv_data_to_df/build.py index 7af672f..878e84b 100644 --- a/q01_read_csv_data_to_df/build.py +++ b/q01_read_csv_data_to_df/build.py @@ -1,8 +1,14 @@ +# %load q01_read_csv_data_to_df/build.py # Default Imports import pandas as pd # Path has been given to you already to use in function. -path = "data/ipl_dataset.csv" +path = 'data/ipl_dataset.csv' + +def read_csv_data_to_df(path='data/ipl_dataset.csv'): + read_csv=pd.read_csv(path) + return read_csv + + -# Solution From 2b605a3568f25b6e46800dc10567427be7d6826c Mon Sep 17 00:00:00 2001 From: aksmungekar Date: Mon, 17 Sep 2018 16:50:18 +0000 Subject: [PATCH 2/7] Done --- q02_get_unique_values/build.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/q02_get_unique_values/build.py b/q02_get_unique_values/build.py index a98550a..6e1750f 100644 --- a/q02_get_unique_values/build.py +++ b/q02_get_unique_values/build.py @@ -1,6 +1,13 @@ +# %load q02_get_unique_values/build.py from greyatomlib.pandas_project.q01_read_csv_data_to_df.build import read_csv_data_to_df # You have been given the dataset already in 'ipl_df'. -ipl_df = read_csv_data_to_df("data/ipl_dataset.csv") +ipl_df = read_csv_data_to_df('data/ipl_dataset.csv') + +def get_unique_venues(): + venue_unique_array=ipl_df['venue'].unique() + return venue_unique_array + + + -#Solution From 8ff2204325f00555970f47c5b87c9a74acb0ceec Mon Sep 17 00:00:00 2001 From: aksmungekar Date: Mon, 17 Sep 2018 17:05:41 +0000 Subject: [PATCH 3/7] Done --- q03_get_run_counts/build.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/q03_get_run_counts/build.py b/q03_get_run_counts/build.py index 07a05ac..3b395f8 100644 --- a/q03_get_run_counts/build.py +++ b/q03_get_run_counts/build.py @@ -1,8 +1,15 @@ +# %load q03_get_run_counts/build.py # Default Imports from greyatomlib.pandas_project.q01_read_csv_data_to_df.build import read_csv_data_to_df # You have been given the dataset already in 'ipl_df'. -ipl_df = read_csv_data_to_df("./data/ipl_dataset.csv") +ipl_df = read_csv_data_to_df('./data/ipl_dataset.csv') + +def get_run_counts(): + runs_count=ipl_df['runs'].value_counts() + return runs_count + + + -# Solution From fd3b1356da3ae024a2306f8d927911f3e6567894 Mon Sep 17 00:00:00 2001 From: aksmungekar Date: Mon, 17 Sep 2018 17:35:29 +0000 Subject: [PATCH 4/7] Done --- q04_get_match_specific_df/build.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/q04_get_match_specific_df/build.py b/q04_get_match_specific_df/build.py index 37ec96a..d8dd05e 100644 --- a/q04_get_match_specific_df/build.py +++ b/q04_get_match_specific_df/build.py @@ -1,7 +1,17 @@ +# %load q04_get_match_specific_df/build.py from greyatomlib.pandas_project.q01_read_csv_data_to_df.build import read_csv_data_to_df # You have been given dataset already in 'ipl_df'. -ipl_df = read_csv_data_to_df("./data/ipl_dataset.csv") +ipl_df = read_csv_data_to_df('./data/ipl_dataset.csv') + +def get_match_specific_df(match_code): + #creating a filter for the given match code through the function + match_code_filter = ipl_df['match_code']==match_code + #applying the above created filter to the main data frame and assigining it to a variable + match_info=ipl_df[match_code_filter] + return match_info + + + -# Solution From 851ede3cbc9a87feeaa7541020c9cc958865eafb Mon Sep 17 00:00:00 2001 From: aksmungekar Date: Mon, 17 Sep 2018 17:55:52 +0000 Subject: [PATCH 5/7] Done --- q05_create_bowler_filter/build.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/q05_create_bowler_filter/build.py b/q05_create_bowler_filter/build.py index 5c15aaa..cdc0b8b 100644 --- a/q05_create_bowler_filter/build.py +++ b/q05_create_bowler_filter/build.py @@ -1,7 +1,12 @@ +# %load q05_create_bowler_filter/build.py # Default imports from greyatomlib.pandas_project.q01_read_csv_data_to_df.build import read_csv_data_to_df # You have been given dataset already in 'ipl_df'. -ipl_df = read_csv_data_to_df("./data/ipl_dataset.csv") +ipl_df = read_csv_data_to_df('./data/ipl_dataset.csv') + +def create_bowler_filter(bowler): + bowler_filter=ipl_df['bowler']==bowler + return bowler_filter + -# Solution From 44895f87adefa5387084afe9ecb4cc97fce0ed20 Mon Sep 17 00:00:00 2001 From: aksmungekar Date: Mon, 17 Sep 2018 18:15:17 +0000 Subject: [PATCH 6/7] Done --- q06_get_match_innings_runs/build.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/q06_get_match_innings_runs/build.py b/q06_get_match_innings_runs/build.py index d938fc2..0f11654 100644 --- a/q06_get_match_innings_runs/build.py +++ b/q06_get_match_innings_runs/build.py @@ -1,11 +1,13 @@ +# %load q06_get_match_innings_runs/build.py # Default Imports from greyatomlib.pandas_project.q01_read_csv_data_to_df.build import read_csv_data_to_df # You have been given dataset already in 'ipl_df'. -ipl_df = read_csv_data_to_df("data/ipl_dataset.csv") - -# Solution +ipl_df = read_csv_data_to_df('data/ipl_dataset.csv') +def get_match_innings_runs(): + innings_summary=ipl_df.groupby(['match_code', 'inning'])[['runs']].sum() + return innings_summary From 1fad456cd401587cf95075cba90c9a9c84074114 Mon Sep 17 00:00:00 2001 From: aksmungekar Date: Tue, 18 Sep 2018 17:13:27 +0000 Subject: [PATCH 7/7] Done --- q07_get_run_counts_by_match/build.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/q07_get_run_counts_by_match/build.py b/q07_get_run_counts_by_match/build.py index a18e534..7592154 100644 --- a/q07_get_run_counts_by_match/build.py +++ b/q07_get_run_counts_by_match/build.py @@ -1,7 +1,16 @@ +# %load q07_get_run_counts_by_match/build.py # Default Imports from greyatomlib.pandas_project.q01_read_csv_data_to_df.build import read_csv_data_to_df +import pandas as pd +import numpy as np # You have been give the dataset already in 'ipl_df'. -ipl_df = read_csv_data_to_df("./data/ipl_dataset.csv") +ipl_df = read_csv_data_to_df('./data/ipl_dataset.csv') +def get_runs_counts_by_match(): + runs_per_match=ipl_df.pivot_table(values='batsman',index=['match_code'],columns=('runs'),aggfunc='count') + #value synbolises the runs scored by batsman + return runs_per_match +get_runs_counts_by_match() + + -# Solution