From 3e5b19bf9ad311f4931e48d6ad6953a6d59fc716 Mon Sep 17 00:00:00 2001 From: akashhchatterjee Date: Sun, 7 Oct 2018 06:21:30 +0000 Subject: [PATCH 1/7] Done --- q01_read_csv_data_to_df/build.py | 7 ++++++- 1 file changed, 6 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..e46288a 100644 --- a/q01_read_csv_data_to_df/build.py +++ b/q01_read_csv_data_to_df/build.py @@ -1,8 +1,13 @@ +# %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_data = pd.read_csv(path) + return df_data +read_csv_data_to_df(path) From aad396a1914957144afec776187744a93a8bdb54 Mon Sep 17 00:00:00 2001 From: akashhchatterjee Date: Sun, 7 Oct 2018 06:30:51 +0000 Subject: [PATCH 2/7] Done --- q02_get_unique_values/build.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/q02_get_unique_values/build.py b/q02_get_unique_values/build.py index a98550a..2f03706 100644 --- a/q02_get_unique_values/build.py +++ b/q02_get_unique_values/build.py @@ -1,6 +1,12 @@ +# %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 1d1d0c894246f61426ba5550b38aac17e2629955 Mon Sep 17 00:00:00 2001 From: akashhchatterjee Date: Sun, 7 Oct 2018 06:59:04 +0000 Subject: [PATCH 3/7] Done --- q03_get_run_counts/build.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/q03_get_run_counts/build.py b/q03_get_run_counts/build.py index 07a05ac..4331f51 100644 --- a/q03_get_run_counts/build.py +++ b/q03_get_run_counts/build.py @@ -1,8 +1,14 @@ +# %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 +import collections # 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(): + frequency = pd.Series(collections.Counter(ipl_df['runs']), index=set(ipl_df['runs'])) + return frequency +get_run_counts() From ceb213f50c7b7792523e475cb080768606cc22e9 Mon Sep 17 00:00:00 2001 From: akashhchatterjee Date: Sun, 7 Oct 2018 08:52:56 +0000 Subject: [PATCH 4/7] Done --- q04_get_match_specific_df/build.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/q04_get_match_specific_df/build.py b/q04_get_match_specific_df/build.py index 37ec96a..92123f0 100644 --- a/q04_get_match_specific_df/build.py +++ b/q04_get_match_specific_df/build.py @@ -1,7 +1,13 @@ +# %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): + match_data = ipl_df[ipl_df['match_code'] == match_code] + return match_data +get_match_specific_df(598057) + From aa4182c783ae58a1cb248225d818b5db55d21271 Mon Sep 17 00:00:00 2001 From: akashhchatterjee Date: Mon, 8 Oct 2018 16:21:44 +0000 Subject: [PATCH 5/7] Done --- q05_create_bowler_filter/build.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/q05_create_bowler_filter/build.py b/q05_create_bowler_filter/build.py index 5c15aaa..777d4b9 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 # 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): + bowler_data = ipl_df['bowler'] == bowler + return bowler_data +create_bowler_filter('I Sharma') + From 4b62926b79f3127143987e34f6ba22b2398500a0 Mon Sep 17 00:00:00 2001 From: akashhchatterjee Date: Sun, 14 Oct 2018 05:44:43 +0000 Subject: [PATCH 6/7] Done --- q06_get_match_innings_runs/build.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/q06_get_match_innings_runs/build.py b/q06_get_match_innings_runs/build.py index d938fc2..d8680c6 100644 --- a/q06_get_match_innings_runs/build.py +++ b/q06_get_match_innings_runs/build.py @@ -1,11 +1,14 @@ +# %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") +ipl_df = read_csv_data_to_df('data/ipl_dataset.csv') # Solution - - +def get_match_innings_runs(): + ininnigs_runs = ipl_df[['match_code','inning','runs']].groupby(['match_code','inning']).sum() + return ininnigs_runs +get_match_innings_runs() From c514a5641b25ecc727da6a27003bb359bed5532b Mon Sep 17 00:00:00 2001 From: akashhchatterjee Date: Sun, 14 Oct 2018 08:01:49 +0000 Subject: [PATCH 7/7] Done --- q07_get_run_counts_by_match/build.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/q07_get_run_counts_by_match/build.py b/q07_get_run_counts_by_match/build.py index a18e534..cee1ac1 100644 --- a/q07_get_run_counts_by_match/build.py +++ b/q07_get_run_counts_by_match/build.py @@ -1,7 +1,13 @@ +# %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 # 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') # Solution +def get_runs_counts_by_match(): + ipl_df['frequency'] = 1 + pivot_runs = ipl_df.pivot_table(values = 'frequency', index = 'match_code', columns = 'runs', aggfunc = 'count') + return pivot_runs +get_runs_counts_by_match() +