From 54350a788cb5353f47f9638c720f5a1b1538c8d3 Mon Sep 17 00:00:00 2001 From: iampa1 Date: Tue, 9 Oct 2018 12:40:54 +0000 Subject: [PATCH 1/7] Done --- q01_read_csv_data_to_df/build.py | 9 ++++++++- 1 file changed, 8 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..0d78f8c 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' # Solution +def read_csv_data_to_df(path): + return pd.read_csv(path) + +path +read_csv_data_to_df(path) + From a6c933ce9575530dc2e3fd4904226d11c854ae2d Mon Sep 17 00:00:00 2001 From: iampa1 Date: Tue, 9 Oct 2018 12:44:40 +0000 Subject: [PATCH 2/7] Done --- q02_get_unique_values/build.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/q02_get_unique_values/build.py b/q02_get_unique_values/build.py index a98550a..c30e318 100644 --- a/q02_get_unique_values/build.py +++ b/q02_get_unique_values/build.py @@ -1,6 +1,12 @@ +# %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') #Solution +def get_unique_venues(): + return ipl_df.venue.unique() +get_unique_venues() + + From 4fc9609995f96964a517395bfb0ad2344995c05d Mon Sep 17 00:00:00 2001 From: iampa1 Date: Tue, 9 Oct 2018 12:51:46 +0000 Subject: [PATCH 3/7] Done --- q03_get_run_counts/build.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/q03_get_run_counts/build.py b/q03_get_run_counts/build.py index 07a05ac..366cbf1 100644 --- a/q03_get_run_counts/build.py +++ b/q03_get_run_counts/build.py @@ -1,8 +1,15 @@ +# %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') # Solution +def get_run_counts(): + return ipl_df.runs.value_counts() + + + + From aaa3c1106bf8f49d85973117788328c87bd06c86 Mon Sep 17 00:00:00 2001 From: iampa1 Date: Fri, 12 Oct 2018 16:20:40 +0000 Subject: [PATCH 4/7] Done --- q04_get_match_specific_df/build.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/q04_get_match_specific_df/build.py b/q04_get_match_specific_df/build.py index 37ec96a..75312af 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 +def get_match_specific_df(some_value): + df=ipl_df + return df.loc[df['match_code'] == some_value] + + + +df=ipl_df +some_value=598057 +df +df.loc[df['match_code'] == some_value] + + From 7f120a28f0b3e08dae45d0112d3349162a6745a7 Mon Sep 17 00:00:00 2001 From: iampa1 Date: Sat, 13 Oct 2018 04:19:15 +0000 Subject: [PATCH 5/7] Done --- q05_create_bowler_filter/build.py | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/q05_create_bowler_filter/build.py b/q05_create_bowler_filter/build.py index 5c15aaa..60bf3d4 100644 --- a/q05_create_bowler_filter/build.py +++ b/q05_create_bowler_filter/build.py @@ -1,7 +1,25 @@ +# %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') # Solution +def create_bowler_filter(some_value): + df=ipl_df + l=df['bowler'] == some_value + return l +df=ipl_df +some_value='I Sharma' +l=[df['bowler'] == some_value] + +import pandas as pd +s=pd.Series([l]) +s.head() +pd.Series([l]).cumsum() +l=[df['bowler'] == 'I Sharma'] + +pd.Series(l) + + From af639cc220f42dfd82d1616478314e811ba45859 Mon Sep 17 00:00:00 2001 From: iampa1 Date: Mon, 15 Oct 2018 06:58:35 +0000 Subject: [PATCH 6/7] Done --- q06_get_match_innings_runs/build.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/q06_get_match_innings_runs/build.py b/q06_get_match_innings_runs/build.py index d938fc2..2763ee6 100644 --- a/q06_get_match_innings_runs/build.py +++ b/q06_get_match_innings_runs/build.py @@ -1,11 +1,28 @@ +# %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(): + df = ipl_df + return df.loc[:, ['runs']] + #l=df.groupby(['match_code','inning','runs']) + #return l + +df=ipl_df +df.loc[:, ['runs','match_code', 'inning']] + +d=get_match_innings_runs() +d.sum() +type(d.sum()) +l=df.groupby(['match_code','inning','runs']) +l.sum() + + From cb69ba09142a67dfa49f216eeb7444b2f6d414b8 Mon Sep 17 00:00:00 2001 From: iampa1 Date: Tue, 16 Oct 2018 06:14:40 +0000 Subject: [PATCH 7/7] Done --- q07_get_run_counts_by_match/build.py | 15 +++++++++++++-- 1 file changed, 13 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..672a508 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 +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') # Solution +def get_runs_counts_by_match(): + table = pd.pivot_table(ipl_df, index=['match_code'],values=['runs'],columns=['total'],aggfunc=np.sum,fill_value=0) + return table.iloc[:,:-1] + + + + + +