From bb2134979a6bf48f6d08fea5664babe6532f2ed1 Mon Sep 17 00:00:00 2001 From: Ajpalav Date: Wed, 26 Sep 2018 05:52:21 +0000 Subject: [PATCH 1/7] Done --- q01_read_csv_data_to_df/build.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/q01_read_csv_data_to_df/build.py b/q01_read_csv_data_to_df/build.py index 7af672f..3338daf 100644 --- a/q01_read_csv_data_to_df/build.py +++ b/q01_read_csv_data_to_df/build.py @@ -1,8 +1,13 @@ -# Default Imports +#%load q01_read_csv_data_to_df/build.py + import pandas as pd +path='./data/ipl_dataset.csv' +def read_csv_data_to_df(path): + df=pd.read_csv(path) + + return df + + -# Path has been given to you already to use in function. -path = "data/ipl_dataset.csv" -# Solution From bd2dfbb8923582df04ffcad4c50a590718b08b4f Mon Sep 17 00:00:00 2001 From: Ajpalav Date: Wed, 26 Sep 2018 05:58:23 +0000 Subject: [PATCH 2/7] Done --- q02_get_unique_values/build.py | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/q02_get_unique_values/build.py b/q02_get_unique_values/build.py index a98550a..700ef66 100644 --- a/q02_get_unique_values/build.py +++ b/q02_get_unique_values/build.py @@ -1,6 +1,18 @@ -from greyatomlib.pandas_project.q01_read_csv_data_to_df.build import read_csv_data_to_df +#%load q02_get_unique_values/build.py + +import pandas as pd + +path='./data/ipl_dataset.csv' + +def get_unique_venues(): + df=pd.read_csv(path) + + venue=df.venue.unique() + + return venue + + + + -# You have been given the dataset already in 'ipl_df'. -ipl_df = read_csv_data_to_df("data/ipl_dataset.csv") -#Solution From 3c983ffe6dc0237cf83d99c28775a0edf636caa4 Mon Sep 17 00:00:00 2001 From: Ajpalav Date: Wed, 26 Sep 2018 06:12:16 +0000 Subject: [PATCH 3/7] Done --- q03_get_run_counts/build.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/q03_get_run_counts/build.py b/q03_get_run_counts/build.py index 07a05ac..161e6c6 100644 --- a/q03_get_run_counts/build.py +++ b/q03_get_run_counts/build.py @@ -1,8 +1,14 @@ -# Default Imports -from greyatomlib.pandas_project.q01_read_csv_data_to_df.build import read_csv_data_to_df +#%load q03_get_run_counts/build.py -# You have been given the dataset already in 'ipl_df'. -ipl_df = read_csv_data_to_df("./data/ipl_dataset.csv") +import pandas as pd +path='./data/ipl_dataset.csv' + +def get_run_counts(): + df=pd.read_csv(path) + + grp=df.groupby(df.runs)['runs'].count() + + #print(type(grp)) + return grp -# Solution From b5115979b0a72c669bb9d0de2204dfc4bb9dfcdf Mon Sep 17 00:00:00 2001 From: Ajpalav Date: Sun, 25 Nov 2018 17:22:11 +0000 Subject: [PATCH 4/7] Done --- q04_get_match_specific_df/build.py | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/q04_get_match_specific_df/build.py b/q04_get_match_specific_df/build.py index 37ec96a..fa8d260 100644 --- a/q04_get_match_specific_df/build.py +++ b/q04_get_match_specific_df/build.py @@ -1,7 +1,22 @@ -from greyatomlib.pandas_project.q01_read_csv_data_to_df.build import read_csv_data_to_df +# %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 numpy as np +import pandas as pd +ifl_df=pd.read_csv('./data/ipl_dataset.csv') + + +def get_match_specific_df(match_code): + + + + #df=ifl_df[(ifl_df['match_code']==match_code)] + df=ifl_df[ifl_df.match_code==match_code] + return df + +get_match_specific_df(598057) + + -# You have been given dataset already in 'ipl_df'. -ipl_df = read_csv_data_to_df("./data/ipl_dataset.csv") -# Solution From b946a86db1898a61b70d55c3949a7780df1ae877 Mon Sep 17 00:00:00 2001 From: Ajpalav Date: Sun, 25 Nov 2018 17:35:46 +0000 Subject: [PATCH 5/7] Done --- q05_create_bowler_filter/build.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/q05_create_bowler_filter/build.py b/q05_create_bowler_filter/build.py index 5c15aaa..d7fe921 100644 --- a/q05_create_bowler_filter/build.py +++ b/q05_create_bowler_filter/build.py @@ -1,7 +1,16 @@ -# Default imports -from greyatomlib.pandas_project.q01_read_csv_data_to_df.build import read_csv_data_to_df +#%load q05_create_bowler_filter/build.py +import pandas as pd +import numpy as np + +ifl_df=pd.read_csv('./data/ipl_dataset.csv') + +def create_bowler_filter(bowler): + + bl=ifl_df['bowler'] + + return bl==bowler + + + -# You have been given dataset already in 'ipl_df'. -ipl_df = read_csv_data_to_df("./data/ipl_dataset.csv") -# Solution From 8b612bf174fa18f6118e453fdf37118c42957945 Mon Sep 17 00:00:00 2001 From: Ajpalav Date: Mon, 26 Nov 2018 06:14:31 +0000 Subject: [PATCH 6/7] Done --- q06_get_match_innings_runs/build.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/q06_get_match_innings_runs/build.py b/q06_get_match_innings_runs/build.py index d938fc2..96ff497 100644 --- a/q06_get_match_innings_runs/build.py +++ b/q06_get_match_innings_runs/build.py @@ -1,10 +1,14 @@ -# Default Imports -from greyatomlib.pandas_project.q01_read_csv_data_to_df.build import read_csv_data_to_df +#%load q06_get_match_innings_runs/build.py +import pandas as pd +import numpy as np -# You have been given dataset already in 'ipl_df'. -ipl_df = read_csv_data_to_df("data/ipl_dataset.csv") +ifl_df=pd.read_csv('./data/ipl_dataset.csv') -# Solution +def get_match_innings_runs(): + + ifl_df2=ifl_df.groupby(['match_code','inning'])['runs'].sum() + + return ifl_df2 From 901c4f514969ae23c3636095daf009896cf2229f Mon Sep 17 00:00:00 2001 From: Ajpalav Date: Wed, 28 Nov 2018 02:07:35 +0000 Subject: [PATCH 7/7] Done --- q07_get_run_counts_by_match/build.py | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/q07_get_run_counts_by_match/build.py b/q07_get_run_counts_by_match/build.py index a18e534..35d4f75 100644 --- a/q07_get_run_counts_by_match/build.py +++ b/q07_get_run_counts_by_match/build.py @@ -1,7 +1,19 @@ -# Default Imports -from greyatomlib.pandas_project.q01_read_csv_data_to_df.build import read_csv_data_to_df +#%load q07_get_run_counts_by_match/build.py + + +import pandas as pd +import numpy as np + +df=pd.read_csv('./data/ipl_dataset.csv') +#df.columns +def get_runs_counts_by_match(): + + df1=df.pivot_table(index='match_code',columns='runs',values='batsman',aggfunc='count') + + return df1 + +get_runs_counts_by_match() +# gr=df.groupby('match_code') +# gr['runs'].sum() -# You have been give the dataset already in 'ipl_df'. -ipl_df = read_csv_data_to_df("./data/ipl_dataset.csv") -# Solution