From c43cf24d2ad4560e7c65030af09c437058cafb9a Mon Sep 17 00:00:00 2001 From: sunilhariharan Date: Sun, 16 Sep 2018 19:01:48 +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..38740ae 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): + + df=pd.read_csv(path) + + return df + + From a237f24edd9b6a07631dc367f4125aaf30fa008d Mon Sep 17 00:00:00 2001 From: sunilhariharan Date: Sun, 16 Sep 2018 19:09:31 +0000 Subject: [PATCH 2/7] Done --- q02_get_unique_values/build.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/q02_get_unique_values/build.py b/q02_get_unique_values/build.py index a98550a..915d0e6 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') +import pandas as pd +import numpy as np #Solution +def get_unique_venues(): + + venues=np.unique(ipl_df['venue'].values) + + return venues + + From 65992374a1a2f43766c9f70a281f1db31aac7f93 Mon Sep 17 00:00:00 2001 From: sunilhariharan Date: Sun, 16 Sep 2018 19:13:49 +0000 Subject: [PATCH 3/7] Done --- q03_get_run_counts/build.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/q03_get_run_counts/build.py b/q03_get_run_counts/build.py index 07a05ac..8d3c8c3 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 # 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') +import pandas as pd +import numpy as np # Solution +def get_run_counts(): + + unique,counts=np.unique(ipl_df['runs'].values,return_counts=True) + d=dict(zip(unique,counts)) + runs_count=pd.Series(d) + + return runs_count + From d5e1093128f554594bba3eb10894742fc20870a8 Mon Sep 17 00:00:00 2001 From: sunilhariharan Date: Mon, 17 Sep 2018 10:09:29 +0000 Subject: [PATCH 4/7] Done --- q04_get_match_specific_df/build.py | 15 ++++++++++++++- q05_create_bowler_filter/build.py | 8 ++++++-- q06_get_match_innings_runs/build.py | 10 ++++++++-- 3 files changed, 28 insertions(+), 5 deletions(-) diff --git a/q04_get_match_specific_df/build.py b/q04_get_match_specific_df/build.py index 37ec96a..fc1309e 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 # 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 +import numpy as np +import pandas as pd + +def get_match_specific_df(match_code): + + df1=ipl_df.groupby(match_code).get_group(392203) + + return df1 + + + + diff --git a/q05_create_bowler_filter/build.py b/q05_create_bowler_filter/build.py index 5c15aaa..0df21de 100644 --- a/q05_create_bowler_filter/build.py +++ b/q05_create_bowler_filter/build.py @@ -1,7 +1,11 @@ +# %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') +impo # Solution + + + diff --git a/q06_get_match_innings_runs/build.py b/q06_get_match_innings_runs/build.py index d938fc2..e979ed1 100644 --- a/q06_get_match_innings_runs/build.py +++ b/q06_get_match_innings_runs/build.py @@ -1,10 +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') +import pandas as pd # Solution +def get_match_innings_runs(): + + df1=ipl_df.groupby(['match_code','inning']).agg({'runs':sum}) + + return df1 From cc1f3d91a51ade3230f2c5247d8248597b933342 Mon Sep 17 00:00:00 2001 From: sunilhariharan Date: Mon, 17 Sep 2018 10:45:43 +0000 Subject: [PATCH 5/7] Done --- q05_create_bowler_filter/build.py | 11 +++++++++-- q07_get_run_counts_by_match/build.py | 11 ++++++++++- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/q05_create_bowler_filter/build.py b/q05_create_bowler_filter/build.py index 0df21de..9ce0852 100644 --- a/q05_create_bowler_filter/build.py +++ b/q05_create_bowler_filter/build.py @@ -4,8 +4,15 @@ # You have been given dataset already in 'ipl_df'. ipl_df = read_csv_data_to_df('./data/ipl_dataset.csv') -impo +import pandas as pd +import numpy as np # Solution - +def create_bowler_filter(bowler): + + s=pd.Series(ipl_df['bowler']) + series=s.isin(['I Sharma']) + + return series + diff --git a/q07_get_run_counts_by_match/build.py b/q07_get_run_counts_by_match/build.py index a18e534..c25352a 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 # 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') +import pandas as pd # Solution +def get_runs_counts_by_match(): + + df=pd.pivot_table(ipl_df,index='match_code',columns='runs',aggfunc='count') + + return df + + From 8f3693ab86586ca9c6b30279fcf07e79efe3c8ca Mon Sep 17 00:00:00 2001 From: sunilhariharan Date: Mon, 17 Sep 2018 11:00:35 +0000 Subject: [PATCH 6/7] Done --- q04_get_match_specific_df/build.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/q04_get_match_specific_df/build.py b/q04_get_match_specific_df/build.py index fc1309e..5794f1c 100644 --- a/q04_get_match_specific_df/build.py +++ b/q04_get_match_specific_df/build.py @@ -10,7 +10,7 @@ def get_match_specific_df(match_code): - df1=ipl_df.groupby(match_code).get_group(392203) + df1=ipl_df.groupby('match_code').get_group(598057) return df1 From 261e6647249dfdb37dd14cd6149a75743674fc48 Mon Sep 17 00:00:00 2001 From: sunilhariharan Date: Mon, 17 Sep 2018 17:51:23 +0000 Subject: [PATCH 7/7] Done --- q07_get_run_counts_by_match/build.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/q07_get_run_counts_by_match/build.py b/q07_get_run_counts_by_match/build.py index c25352a..427e361 100644 --- a/q07_get_run_counts_by_match/build.py +++ b/q07_get_run_counts_by_match/build.py @@ -9,8 +9,11 @@ # Solution def get_runs_counts_by_match(): - df=pd.pivot_table(ipl_df,index='match_code',columns='runs',aggfunc='count') + df=pd.pivot_table(ipl_df,index='match_code',columns='runs',aggfunc='count').iloc[:,0:7] return df + + +