From baa14f5273f74f83256295807b71d4d019f71190 Mon Sep 17 00:00:00 2001 From: RohanUnni Date: Fri, 21 Sep 2018 11:56:17 +0000 Subject: [PATCH 1/7] Done --- q01_read_csv_data_to_df/build.py | 6 +++++- 1 file changed, 5 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..38aafc7 100644 --- a/q01_read_csv_data_to_df/build.py +++ b/q01_read_csv_data_to_df/build.py @@ -1,8 +1,12 @@ +# %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): + return pd.read_csv(path) +read_csv_data_to_df(path) From b0329e3ebc35024dc51ea4e311a2c22cc64fe53c Mon Sep 17 00:00:00 2001 From: RohanUnni Date: Fri, 21 Sep 2018 14:43:43 +0000 Subject: [PATCH 2/7] Done --- q02_get_unique_values/build.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/q02_get_unique_values/build.py b/q02_get_unique_values/build.py index a98550a..050ad05 100644 --- a/q02_get_unique_values/build.py +++ b/q02_get_unique_values/build.py @@ -1,6 +1,11 @@ +# %load q02_get_unique_values/build.py 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_unique_venues(): + return pd.unique(ipl_df['venue']) +get_unique_venues() + From d71145f888ca5cd567dadd597be7dc8c7bc6bd86 Mon Sep 17 00:00:00 2001 From: RohanUnni Date: Fri, 21 Sep 2018 18:01:50 +0000 Subject: [PATCH 3/7] Done --- q03_get_run_counts/build.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/q03_get_run_counts/build.py b/q03_get_run_counts/build.py index 07a05ac..d8ba7af 100644 --- a/q03_get_run_counts/build.py +++ b/q03_get_run_counts/build.py @@ -1,8 +1,12 @@ +# %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(): + return pd.Series(pd.unique(ipl_df['runs'].value_counts()), index=pd.unique(ipl_df['runs'])) +get_run_counts() From bf476076eb52a0279e82faa4b8588c0aea8d6381 Mon Sep 17 00:00:00 2001 From: RohanUnni Date: Mon, 24 Sep 2018 13:16:34 +0000 Subject: [PATCH 4/7] Done --- q04_get_match_specific_df/build.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/q04_get_match_specific_df/build.py b/q04_get_match_specific_df/build.py index 37ec96a..060c2e2 100644 --- a/q04_get_match_specific_df/build.py +++ b/q04_get_match_specific_df/build.py @@ -1,7 +1,11 @@ +# %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): + return ipl_df[ipl_df['match_code']==match_code] +get_match_specific_df(598057) From 67813261ae486f480797607f38befacb68ae7e9a Mon Sep 17 00:00:00 2001 From: RohanUnni Date: Mon, 24 Sep 2018 13:57:15 +0000 Subject: [PATCH 5/7] Done --- q05_create_bowler_filter/build.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/q05_create_bowler_filter/build.py b/q05_create_bowler_filter/build.py index 5c15aaa..c2100ab 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') # Solution +def create_bowler_filter(bowler): + return ipl_df['bowler']==bowler +create_bowler_filter('I Sharma') + From 1c1838d3fdc071b566c020fdc5dac0bfc2d952a1 Mon Sep 17 00:00:00 2001 From: RohanUnni Date: Tue, 25 Sep 2018 18:32:41 +0000 Subject: [PATCH 6/7] Done --- q06_get_match_innings_runs/build.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/q06_get_match_innings_runs/build.py b/q06_get_match_innings_runs/build.py index d938fc2..3d0a72e 100644 --- a/q06_get_match_innings_runs/build.py +++ b/q06_get_match_innings_runs/build.py @@ -1,10 +1,15 @@ +# %load q06_get_match_innings_runs/build.py # Default Imports +import numpy as np 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(): + return ipl_df[['match_code','inning','runs']].groupby(['match_code','inning']).agg(np.sum) +get_match_innings_runs() From 530167d535e31032f99eb9341e2ee8817353b5c0 Mon Sep 17 00:00:00 2001 From: RohanUnni Date: Wed, 26 Sep 2018 10:09:36 +0000 Subject: [PATCH 7/7] Done --- q07_get_run_counts_by_match/build.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/q07_get_run_counts_by_match/build.py b/q07_get_run_counts_by_match/build.py index a18e534..63311ee 100644 --- a/q07_get_run_counts_by_match/build.py +++ b/q07_get_run_counts_by_match/build.py @@ -1,7 +1,12 @@ +# %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 # 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(): + return ipl_df.pivot_table(index='match_code',columns='runs',aggfunc='count').iloc[:,:7] +get_runs_counts_by_match() +