From 5a9640eabc9e66beb6f4469fa4c7e59e8bdcbe6c Mon Sep 17 00:00:00 2001 From: sagark93 Date: Thu, 8 Nov 2018 08:48:51 +0000 Subject: [PATCH 1/7] Done --- q01_read_csv_data_to_df/build.py | 8 +++++++- 1 file changed, 7 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..fff745a 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' # Solution +def read_csv_data_to_df (path) : + df = pd.read_csv(path) + return df +df = read_csv_data_to_df (path) +df.shape From 82c4e6e1be81eea6c4ad2552dd0f7d18b6956623 Mon Sep 17 00:00:00 2001 From: sagark93 Date: Thu, 8 Nov 2018 08:57:36 +0000 Subject: [PATCH 2/7] 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..13db1d5 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() : + uni = ipl_df['venue'].unique() + return uni +ipl_df.head() +ipl_df['venue'].unique() + + + From c470f5045b62bfc4bff8b60962429932f12a62d1 Mon Sep 17 00:00:00 2001 From: sagark93 Date: Sun, 11 Nov 2018 06:54:51 +0000 Subject: [PATCH 3/7] Done --- q03_get_run_counts/build.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/q03_get_run_counts/build.py b/q03_get_run_counts/build.py index 07a05ac..e5f9c8f 100644 --- a/q03_get_run_counts/build.py +++ b/q03_get_run_counts/build.py @@ -1,8 +1,17 @@ +# %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() : + for x in ipl_df['runs']: + freq = ipl_df['runs'].value_counts() + return freq + +#ipl_df['runs'] +get_run_counts() + From eefd79fd3d59ab0fdbca8973b55d406ea52d1d9a Mon Sep 17 00:00:00 2001 From: sagark93 Date: Sat, 12 Jan 2019 08:41:32 +0000 Subject: [PATCH 4/7] Done --- q04_get_match_specific_df/build.py | 17 ++++++++++-- q05_create_bowler_filter/build.py | 42 +++++++++++++++++++++++++++++- 2 files changed, 56 insertions(+), 3 deletions(-) diff --git a/q04_get_match_specific_df/build.py b/q04_get_match_specific_df/build.py index 37ec96a..e010323 100644 --- a/q04_get_match_specific_df/build.py +++ b/q04_get_match_specific_df/build.py @@ -1,7 +1,20 @@ +# %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 - +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_specific_df(match_code): + s = pd.Series() + s = ipl_df.loc[ipl_df['match_code'] == match_code] + return s +type(ipl_df['match_code']) +ipl_df.loc[ipl_df['match_code'] == 392203] + +get_match_specific_df(598057) + + + + diff --git a/q05_create_bowler_filter/build.py b/q05_create_bowler_filter/build.py index 5c15aaa..6f8ca06 100644 --- a/q05_create_bowler_filter/build.py +++ b/q05_create_bowler_filter/build.py @@ -1,7 +1,47 @@ +# %load q05_create_bowler_filter/build.py # Default imports +import pandas as pd +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 create_bowler_filter (name): + for x in ipl_df['bowler'] : + s = pd.Series( index = list(x)) + logical_results = str(s) == name + #logical_results_series = pd.Series(np.arange(0,8),index=logical_results) + new = s[logical_results] + return new + #bow_array =pd.Series +# for x in ipl_df['bowler']: + # ipl_df['bowler'] == name + # bow_array = pd.Series(True) + # return bow_array +create_bowler_filter('AB Dinda') + +s = pd.Series( index = list(ipl_df['bowler'])) +s + + + + + + + + + + + + + + + + + + From a1e26bc9e77201c5fa1b6b77cd8611b20c660609 Mon Sep 17 00:00:00 2001 From: sagark93 Date: Thu, 17 Jan 2019 12:00:00 +0000 Subject: [PATCH 5/7] Done --- q07_get_run_counts_by_match/build.py | 15 +++++++++++++-- 1 file changed, 13 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..f641229 100644 --- a/q07_get_run_counts_by_match/build.py +++ b/q07_get_run_counts_by_match/build.py @@ -1,7 +1,18 @@ +# %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') # Solution + +def get_runs_counts_by_match(): + runs_by_match = ipl_df.pivot_table(values='delivery', index='match_code', columns=['runs'], + aggfunc='count') + return runs_by_match +get_runs_counts_by_match() + + + From d40788d55fb1a1b64bd80114fdb1193ffcc96e80 Mon Sep 17 00:00:00 2001 From: sagark93 Date: Fri, 18 Jan 2019 10:16:01 +0000 Subject: [PATCH 6/7] Done --- q05_create_bowler_filter/build.py | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/q05_create_bowler_filter/build.py b/q05_create_bowler_filter/build.py index 6f8ca06..72c3f9e 100644 --- a/q05_create_bowler_filter/build.py +++ b/q05_create_bowler_filter/build.py @@ -12,21 +12,25 @@ def create_bowler_filter (name): - for x in ipl_df['bowler'] : - s = pd.Series( index = list(x)) - logical_results = str(s) == name + for x in ipl_df['bowler']: + #s = pd.Series( index = list(x)) + s = pd.Series(ipl_df['bowler'] == name) + #logical_results = str(s) == name #logical_results_series = pd.Series(np.arange(0,8),index=logical_results) - new = s[logical_results] - return new + #new = s[logical_results] + #return new + return s #bow_array =pd.Series -# for x in ipl_df['bowler']: - # ipl_df['bowler'] == name - # bow_array = pd.Series(True) +#for x in ipl_df['bowler']: + #ipl_df['bowler'] == name + #bow_array = pd.Series(True) # return bow_array -create_bowler_filter('AB Dinda') +create_bowler_filter('I Sharma').shape -s = pd.Series( index = list(ipl_df['bowler'])) -s +#if ipl_df['bowler'] == 'AB Dinda': + # boolean_value = True +#else: + # boolean_value = False From 549f0f91bb18ae16250388b828863e5ef4496a69 Mon Sep 17 00:00:00 2001 From: sagark93 Date: Fri, 18 Jan 2019 11:39:41 +0000 Subject: [PATCH 7/7] Done --- q06_get_match_innings_runs/build.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/q06_get_match_innings_runs/build.py b/q06_get_match_innings_runs/build.py index d938fc2..7447e54 100644 --- a/q06_get_match_innings_runs/build.py +++ b/q06_get_match_innings_runs/build.py @@ -1,11 +1,16 @@ +# %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 +## Solution +def get_match_innings_runs(): + result = ipl_df.groupby(['match_code','inning'])['runs'].sum() + return result +get_match_innings_runs()