From 34e104f515a5308ad62a28a4e0b076cec440e565 Mon Sep 17 00:00:00 2001 From: Sandesh373 Date: Tue, 9 Oct 2018 11:27:29 +0000 Subject: [PATCH 1/8] Done --- q01_read_csv_data_to_df/build.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/q01_read_csv_data_to_df/build.py b/q01_read_csv_data_to_df/build.py index 7af672f..778ba87 100644 --- a/q01_read_csv_data_to_df/build.py +++ b/q01_read_csv_data_to_df/build.py @@ -1,8 +1,15 @@ +# %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' + +def read_csv_data_to_df(path): + data=pd.read_csv(path) + return data + + +read_csv_data_to_df('data/ipl_dataset.csv') -# Solution From 5b276b4c228cdfdebdb83de2530729de18d62de5 Mon Sep 17 00:00:00 2001 From: Sandesh373 Date: Tue, 9 Oct 2018 11:34:57 +0000 Subject: [PATCH 2/8] 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..37681fb 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') + +def get_unique_venues(): + + return ipl_df.venue.unique() + +get_unique_venues() + -#Solution From ec89b6654fb549f0fa58afe047167cdee7e954b2 Mon Sep 17 00:00:00 2001 From: Sandesh373 Date: Tue, 9 Oct 2018 11:40:50 +0000 Subject: [PATCH 3/8] Done --- q03_get_run_counts/build.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/q03_get_run_counts/build.py b/q03_get_run_counts/build.py index 07a05ac..4463bfe 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') + +def get_run_counts(): + return ipl_df['runs'].value_counts() + + +get_run_counts() -# Solution From 4c2c3c0844992a05720d5020dbe19229e2a2cae3 Mon Sep 17 00:00:00 2001 From: Sandesh373 Date: Tue, 9 Oct 2018 11:51:33 +0000 Subject: [PATCH 4/8] Done --- q04_get_match_specific_df/build.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/q04_get_match_specific_df/build.py b/q04_get_match_specific_df/build.py index 37ec96a..623caaf 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 +import pandas as pd 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') + +def get_match_specific_df(match_code): + ipl_match=ipl_df['match_code']==match_code + match_info=ipl_df[ipl_match] + return match_info + + +get_match_specific_df(392203) -# Solution From 4090f1b8f0f41ba2c7649c7fcfe0cbcb2bf7d463 Mon Sep 17 00:00:00 2001 From: Sandesh373 Date: Tue, 9 Oct 2018 11:57:34 +0000 Subject: [PATCH 5/8] Done --- q05_create_bowler_filter/build.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/q05_create_bowler_filter/build.py b/q05_create_bowler_filter/build.py index 5c15aaa..1e7e011 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') + +def create_bowler_filter(bowler): + fil_bowler=ipl_df['bowler']==bowler + return fil_bowler + + +create_bowler_filter('b I Sharma') + -# Solution From c869f9e83884ba46971bb4d6ac40404ccfa9c978 Mon Sep 17 00:00:00 2001 From: Sandesh373 Date: Fri, 23 Nov 2018 09:03:23 +0000 Subject: [PATCH 6/8] Done --- q06_get_match_innings_runs/build.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/q06_get_match_innings_runs/build.py b/q06_get_match_innings_runs/build.py index d938fc2..1e34302 100644 --- a/q06_get_match_innings_runs/build.py +++ b/q06_get_match_innings_runs/build.py @@ -1,11 +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 # 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 ipl_df.groupby(['match_code', 'inning'])['runs'].sum() + +get_match_innings_runs() + + From 643b8adfb86023f8e56eb1a7a06ca595fb9f1625 Mon Sep 17 00:00:00 2001 From: Sandesh373 Date: Thu, 27 Dec 2018 09:37:15 +0000 Subject: [PATCH 7/8] Done --- q07_get_run_counts_by_match/build.py | 16 ++++++++++++++-- 1 file changed, 14 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..4881db5 100644 --- a/q07_get_run_counts_by_match/build.py +++ b/q07_get_run_counts_by_match/build.py @@ -1,7 +1,19 @@ +# %load q07_get_run_counts_by_match/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 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') + +def get_runs_counts_by_match(): + df1=ipl_df[['match_code','runs']] + df=pd.pivot_table(df1,index='match_code',columns='runs',aggfunc=len) + return df + +df1=ipl_df[['match_code','runs']] +df=pd.pivot_table(df1,index='match_code',columns='runs',aggfunc=len) +df + -# Solution From 0a74acf0c0153148d2142ec6daa7c25ca0b0c87a Mon Sep 17 00:00:00 2001 From: Sandesh373 Date: Thu, 27 Dec 2018 10:23:14 +0000 Subject: [PATCH 8/8] Done --- q07_get_run_counts_by_match/build.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/q07_get_run_counts_by_match/build.py b/q07_get_run_counts_by_match/build.py index 4881db5..f3690a8 100644 --- a/q07_get_run_counts_by_match/build.py +++ b/q07_get_run_counts_by_match/build.py @@ -12,8 +12,5 @@ def get_runs_counts_by_match(): df=pd.pivot_table(df1,index='match_code',columns='runs',aggfunc=len) return df -df1=ipl_df[['match_code','runs']] -df=pd.pivot_table(df1,index='match_code',columns='runs',aggfunc=len) -df