From 9db0b39bc08bd34b7d63932ae95e5e9694d37242 Mon Sep 17 00:00:00 2001 From: Jas-simran Date: Fri, 28 Sep 2018 11:20:44 +0000 Subject: [PATCH 1/7] Done --- q01_read_csv_data_to_df/build.py | 12 +++++++++++- 1 file changed, 11 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..6dcbf17 100644 --- a/q01_read_csv_data_to_df/build.py +++ b/q01_read_csv_data_to_df/build.py @@ -1,8 +1,18 @@ +# %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): + data = pd.read_csv(path) + df=pd.DataFrame(data) + return df + + + +read_csv_data_to_df(path) + From 84068af9f8f5b6ac7d256283e3d213dd7c9714a7 Mon Sep 17 00:00:00 2001 From: Jas-simran Date: Thu, 4 Oct 2018 20:44:29 +0000 Subject: [PATCH 2/7] Done --- q02_get_unique_values/build.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/q02_get_unique_values/build.py b/q02_get_unique_values/build.py index a98550a..d5160c0 100644 --- a/q02_get_unique_values/build.py +++ b/q02_get_unique_values/build.py @@ -1,6 +1,14 @@ +# %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(): + a=ipl_df['venue'].unique() + return a + +get_unique_venues() + + From c9612ba3c25a9129520b861ba4a1c702a6c61de4 Mon Sep 17 00:00:00 2001 From: Jas-simran Date: Thu, 4 Oct 2018 21:10:56 +0000 Subject: [PATCH 3/7] Done --- q03_get_run_counts/build.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/q03_get_run_counts/build.py b/q03_get_run_counts/build.py index 07a05ac..df6f331 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 # 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(): + a = ipl_df['runs'].value_counts() + return a +get_run_counts() + From dc535c645242699706079168caf8e36ef3d7a334 Mon Sep 17 00:00:00 2001 From: Jas-simran Date: Sat, 6 Oct 2018 10:18:09 +0000 Subject: [PATCH 4/7] Done --- q04_get_match_specific_df/build.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/q04_get_match_specific_df/build.py b/q04_get_match_specific_df/build.py index 37ec96a..64afced 100644 --- a/q04_get_match_specific_df/build.py +++ b/q04_get_match_specific_df/build.py @@ -1,7 +1,16 @@ +# %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): + a=ipl_df[ipl_df['match_code']==598057] + + return a + + +get_match_specific_df(598057) + From e7de930ab0841bb39cc62c2aaad6139d2690e4a4 Mon Sep 17 00:00:00 2001 From: Jas-simran Date: Sun, 4 Nov 2018 10:28:26 +0000 Subject: [PATCH 5/7] Done --- q05_create_bowler_filter/build.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/q05_create_bowler_filter/build.py b/q05_create_bowler_filter/build.py index 5c15aaa..88bec4c 100644 --- a/q05_create_bowler_filter/build.py +++ b/q05_create_bowler_filter/build.py @@ -1,7 +1,15 @@ +# %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): + a=ipl_df['bowler'] =='I Sharma' + return a + +create_bowler_filter('I Sharma') + + From eff1edc39831266b1ac57db357cb04d7b013db1b Mon Sep 17 00:00:00 2001 From: Jas-simran Date: Sun, 4 Nov 2018 10:38:49 +0000 Subject: [PATCH 6/7] Done --- q06_get_match_innings_runs/build.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/q06_get_match_innings_runs/build.py b/q06_get_match_innings_runs/build.py index d938fc2..e7fea63 100644 --- a/q06_get_match_innings_runs/build.py +++ b/q06_get_match_innings_runs/build.py @@ -1,11 +1,19 @@ +# %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(): + a=ipl_df.groupby(['match_code','inning']).sum()['runs'] + return a + +get_match_innings_runs() + + From 0cefec4b5bfaea56bbb294373341d8c2eb422917 Mon Sep 17 00:00:00 2001 From: Jas-simran Date: Sun, 4 Nov 2018 10:45:05 +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..176744a 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 # 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(): + a=ipl_df[['match_code','runs','batsman']] + b=pd.pivot_table(a,values=['runs'],index=['match_code'],columns=['runs'],aggfunc='count') + return b + +get_runs_counts_by_match() + +