From 6aad9916f68cd8a3edb49b880483397c3705de2d Mon Sep 17 00:00:00 2001 From: vivekshingate Date: Thu, 20 Sep 2018 06:31:57 +0000 Subject: [PATCH 1/7] Done --- q01_read_csv_data_to_df/build.py | 10 +++++++++- 1 file changed, 9 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..da749f8 100644 --- a/q01_read_csv_data_to_df/build.py +++ b/q01_read_csv_data_to_df/build.py @@ -1,8 +1,16 @@ +# %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 0dfca0ba3e631878fab58d3b2e9cfcae73f5d39e Mon Sep 17 00:00:00 2001 From: vivekshingate Date: Thu, 20 Sep 2018 06:37:09 +0000 Subject: [PATCH 2/7] Done --- q02_get_unique_values/build.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/q02_get_unique_values/build.py b/q02_get_unique_values/build.py index a98550a..8eed1ce 100644 --- a/q02_get_unique_values/build.py +++ b/q02_get_unique_values/build.py @@ -1,6 +1,16 @@ +# %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') +#ipl_df.info() #Solution +def get_unique_venues(): + return ipl_df.venue.unique() + +get_unique_venues() + + + + From cc78fc071facc54b01664573cdb7b850d3bcb05a Mon Sep 17 00:00:00 2001 From: vivekshingate Date: Thu, 20 Sep 2018 06:45:56 +0000 Subject: [PATCH 3/7] Done --- q03_get_run_counts/build.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/q03_get_run_counts/build.py b/q03_get_run_counts/build.py index 07a05ac..c5c3d82 100644 --- a/q03_get_run_counts/build.py +++ b/q03_get_run_counts/build.py @@ -1,8 +1,18 @@ +# %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(ipl_df['runs'].value_counts()) + +get_run_counts() + + + + From eb0058ffcbca471ed9c3a9172da7559debd423b1 Mon Sep 17 00:00:00 2001 From: vivekshingate Date: Thu, 20 Sep 2018 19:38:31 +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..d538624 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): + return ipl_df[ipl_df.match_code == match_code] + +#Call to the function +get_match_specific_df(392203) + + + From 0b0cd534e106154f59a8d829f9f5f6d329842903 Mon Sep 17 00:00:00 2001 From: vivekshingate Date: Thu, 20 Sep 2018 19:49:24 +0000 Subject: [PATCH 5/7] Done --- q05_create_bowler_filter/build.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/q05_create_bowler_filter/build.py b/q05_create_bowler_filter/build.py index 5c15aaa..22299bd 100644 --- a/q05_create_bowler_filter/build.py +++ b/q05_create_bowler_filter/build.py @@ -1,7 +1,17 @@ +# %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') + +ipl_df.head() +ipl_df.tail() # Solution +def create_bowler_filter(bowler): + return ipl_df.bowler == bowler + +create_bowler_filter('I Sharma') + + From 8c0fa5c895fdf16982c2529f6ea64b09da8881d9 Mon Sep 17 00:00:00 2001 From: vivekshingate Date: Thu, 20 Sep 2018 20:22:39 +0000 Subject: [PATCH 6/7] Done --- q06_get_match_innings_runs/build.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/q06_get_match_innings_runs/build.py b/q06_get_match_innings_runs/build.py index d938fc2..487a765 100644 --- a/q06_get_match_innings_runs/build.py +++ b/q06_get_match_innings_runs/build.py @@ -1,10 +1,21 @@ +# %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(): + return pd.DataFrame(ipl_df.groupby(['match_code','inning'])['runs'].sum()) + + +get_match_innings_runs() + From 0fe917db00190abff351b529ec094e597f33a3e2 Mon Sep 17 00:00:00 2001 From: vivekshingate Date: Thu, 20 Sep 2018 20:46:31 +0000 Subject: [PATCH 7/7] Done --- q07_get_run_counts_by_match/build.py | 13 ++++++++++++- 1 file changed, 12 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..242b48d 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 + # 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 pd.pivot_table(ipl_df, values = 'batsman', index='match_code', columns = ['runs'], aggfunc='count') + #value synbolises the runs scored by batsman + +#Call to the function +get_runs_counts_by_match() + +