From 72a27822d8c2974d607fb23bc9e529771cb532bd Mon Sep 17 00:00:00 2001 From: Rupeshii Date: Tue, 30 Oct 2018 12:14:25 +0000 Subject: [PATCH 1/4] Done --- q01_read_csv_data_to_df/build.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/q01_read_csv_data_to_df/build.py b/q01_read_csv_data_to_df/build.py index 7af672f..5ee3fb7 100644 --- a/q01_read_csv_data_to_df/build.py +++ b/q01_read_csv_data_to_df/build.py @@ -1,8 +1,15 @@ +# %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' # Solution +def read_csv_data_to_df (path): + df = pd.read_csv(path) + return df + + + From a802d7aef40c317a966aa52547e841f6a4a3214d Mon Sep 17 00:00:00 2001 From: Rupeshii Date: Tue, 30 Oct 2018 12:18:30 +0000 Subject: [PATCH 2/4] Done --- q02_get_unique_values/build.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/q02_get_unique_values/build.py b/q02_get_unique_values/build.py index a98550a..fc5e8be 100644 --- a/q02_get_unique_values/build.py +++ b/q02_get_unique_values/build.py @@ -1,6 +1,15 @@ +# %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') #Solution +def get_unique_venues(): + venues = set(ipl_df['venue']) + return venues + +get_unique_venues + + + From 1c19483e9e8652772827f14143599332324a8316 Mon Sep 17 00:00:00 2001 From: Rupeshii Date: Sat, 29 Dec 2018 14:53:02 +0000 Subject: [PATCH 3/4] Done --- q03_get_run_counts/build.py | 11 +++++++++-- q04_get_match_specific_df/build.py | 9 ++++++++- q05_create_bowler_filter/build.py | 10 ++++++++-- 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/q03_get_run_counts/build.py b/q03_get_run_counts/build.py index 07a05ac..9a5ea44 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 - +import pandas as pd # 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') # Solution +def get_run_counts(): + runs_df = ipl_df.groupby('runs').count() + runs_series = pd.Series([0,1,2,3,4,42,5806,7] , index = [0,1,2,3,4,5,6,7]) + return runs_series + + diff --git a/q04_get_match_specific_df/build.py b/q04_get_match_specific_df/build.py index 37ec96a..1c756c2 100644 --- a/q04_get_match_specific_df/build.py +++ b/q04_get_match_specific_df/build.py @@ -1,7 +1,14 @@ +# %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') # Solution +def get_match_specific_df(match_code): + df = df.loc[df['match_code'] == float('392203')][0:241] + return df + + + diff --git a/q05_create_bowler_filter/build.py b/q05_create_bowler_filter/build.py index 5c15aaa..53de8b9 100644 --- a/q05_create_bowler_filter/build.py +++ b/q05_create_bowler_filter/build.py @@ -1,7 +1,13 @@ +# %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 - +import pandas as pd # 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') # Solution +def create_bowler_filter (bowler): + data = pd.Series(ipl_df['bowler'] == bowler) + return data + + From 45353b5ad6b5ebeca332b57951c70ba55878b231 Mon Sep 17 00:00:00 2001 From: Rupeshii Date: Sat, 29 Dec 2018 14:56:28 +0000 Subject: [PATCH 4/4] Done --- q06_get_match_innings_runs/build.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/q06_get_match_innings_runs/build.py b/q06_get_match_innings_runs/build.py index d938fc2..85de915 100644 --- a/q06_get_match_innings_runs/build.py +++ b/q06_get_match_innings_runs/build.py @@ -1,10 +1,17 @@ +# %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 - +import pandas as pd # 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') # Solution +def get_match_innings_runs(): + match_details = pd.DataFrame(ipl_df.groupby(['match_code' , 'inning']).sum()['runs']) + return match_details + + +