From 90b09c374e64cdf175434846c1f578ecddd80664 Mon Sep 17 00:00:00 2001 From: apurvi02 Date: Tue, 18 Sep 2018 12:35:00 +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..fbcffda 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(p): + a=pd.read_csv(p) + return a +read_csv_data_to_df(path) From fc390717f372cef88fa2c81cd3e972eb78a0f290 Mon Sep 17 00:00:00 2001 From: apurvi02 Date: Tue, 18 Sep 2018 12:39:22 +0000 Subject: [PATCH 2/7] Done --- q02_get_unique_values/build.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/q02_get_unique_values/build.py b/q02_get_unique_values/build.py index a98550a..6cc1bda 100644 --- a/q02_get_unique_values/build.py +++ b/q02_get_unique_values/build.py @@ -1,6 +1,13 @@ +# %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 #Solution +def get_unique_venues(): + a=ipl_df['venue'].unique() + return a +get_unique_venues() + + From 6e8472438d30538e10bf49a13393073870cdef60 Mon Sep 17 00:00:00 2001 From: apurvi02 Date: Tue, 18 Sep 2018 12:55:39 +0000 Subject: [PATCH 3/7] Done --- q03_get_run_counts/build.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/q03_get_run_counts/build.py b/q03_get_run_counts/build.py index 07a05ac..9e54f48 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 # 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 +l=[] # Solution +def get_run_counts(): + l=ipl_df['runs'].value_counts() + return pd.Series(l) +get_run_counts() From 12d17cb9c0154dcc1ef7ada2177a7e80e3875a7c Mon Sep 17 00:00:00 2001 From: apurvi02 Date: Tue, 18 Sep 2018 13:02:25 +0000 Subject: [PATCH 4/7] Done --- q04_get_match_specific_df/build.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/q04_get_match_specific_df/build.py b/q04_get_match_specific_df/build.py index 37ec96a..53062ad 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') +ipl_df +(ipl_df['match_code']) # Solution +def get_match_specific_df(mc): + df=ipl_df[(ipl_df['match_code']==mc)] + return df +get_match_specific_df(598057) From e697523c4b113a6c6fc104174b1cb690cdf67765 Mon Sep 17 00:00:00 2001 From: apurvi02 Date: Tue, 18 Sep 2018 18:30:14 +0000 Subject: [PATCH 5/7] Done --- q05_create_bowler_filter/build.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/q05_create_bowler_filter/build.py b/q05_create_bowler_filter/build.py index 5c15aaa..6865b59 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 - +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') +ipl_df # Solution +def create_bowler_filter(b): + a=pd.Series(ipl_df['bowler']==b) + return a +create_bowler_filter('I Sharma') + From 1764e940a21603e557b7fad2ff41ce85e66496ec Mon Sep 17 00:00:00 2001 From: apurvi02 Date: Tue, 18 Sep 2018 19:07:18 +0000 Subject: [PATCH 6/7] Done --- q06_get_match_innings_runs/build.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/q06_get_match_innings_runs/build.py b/q06_get_match_innings_runs/build.py index d938fc2..6fa6620 100644 --- a/q06_get_match_innings_runs/build.py +++ b/q06_get_match_innings_runs/build.py @@ -1,10 +1,17 @@ +# %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 numpy as np # 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 # Solution +def get_match_innings_runs(): + a=ipl_df.groupby(by=['match_code','inning']).agg(np.sum) + return a[['runs']] +get_match_innings_runs() + + From ca06218e90da17089174d2063ae0e41671370047 Mon Sep 17 00:00:00 2001 From: apurvi02 Date: Tue, 18 Sep 2018 19:27:42 +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..8735e29 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 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') +r=ipl_df['runs'].unique() # Solution +def get_runs_counts_by_match(): + a=ipl_df.pivot_table(index='match_code',columns='runs',aggfunc='count') + return a['batsman'] +get_runs_counts_by_match() +