From 264d9d6610d10c61d96df73154d8514885d6c553 Mon Sep 17 00:00:00 2001 From: savans7 Date: Sun, 16 Sep 2018 03:15:31 +0000 Subject: [PATCH 1/7] Done --- q01_read_csv_data_to_df/build.py | 12 ++++++++---- 1 file changed, 8 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..747567b 100644 --- a/q01_read_csv_data_to_df/build.py +++ b/q01_read_csv_data_to_df/build.py @@ -1,8 +1,12 @@ -# Default Imports import pandas as pd -# Path has been given to you already to use in function. -path = "data/ipl_dataset.csv" +def read_csv_data_to_df(path) : + df=pd.read_csv(path) + data=pd.DataFrame(df) + return data + +print(read_csv_data_to_df('data/ipl_dataset.csv')) + + -# Solution From 5184daead1359128d4946b55ee95e57b1c225a4b Mon Sep 17 00:00:00 2001 From: savans7 Date: Sun, 16 Sep 2018 03:21:20 +0000 Subject: [PATCH 2/7] Done --- q02_get_unique_values/build.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/q02_get_unique_values/build.py b/q02_get_unique_values/build.py index a98550a..835a4fc 100644 --- a/q02_get_unique_values/build.py +++ b/q02_get_unique_values/build.py @@ -1,6 +1,15 @@ -from greyatomlib.pandas_project.q01_read_csv_data_to_df.build import read_csv_data_to_df +import pandas as pd + +def read_csv_data_to_df(path) : + df=pd.read_csv(path) + data=pd.DataFrame(df) + return data + +def get_unique_venues() : + datas=read_csv_data_to_df('data/ipl_dataset.csv'); + return datas.venue.unique() + +print(get_unique_venues()) + -# You have been given the dataset already in 'ipl_df'. -ipl_df = read_csv_data_to_df("data/ipl_dataset.csv") -#Solution From f325e2f4660c0e55e6e13bad887523fa49cf5cbb Mon Sep 17 00:00:00 2001 From: savans7 Date: Sun, 16 Sep 2018 03:37:42 +0000 Subject: [PATCH 3/7] Done --- q03_get_run_counts/build.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/q03_get_run_counts/build.py b/q03_get_run_counts/build.py index 07a05ac..ac4b405 100644 --- a/q03_get_run_counts/build.py +++ b/q03_get_run_counts/build.py @@ -1,8 +1,16 @@ -# 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") +def read_csv_data_to_df(path) : + df=pd.read_csv(path) + data=pd.DataFrame(df) + return data + +def get_run_counts() : + datas=read_csv_data_to_df('data/ipl_dataset.csv'); + #df=datas.groupby('runs').count() + + return datas['runs'].value_counts() + +print(get_run_counts()) -# Solution From 9d7eb567e5aaf17a00e9553700c984bccac75193 Mon Sep 17 00:00:00 2001 From: savans7 Date: Sun, 16 Sep 2018 03:43:25 +0000 Subject: [PATCH 4/7] Done --- q04_get_match_specific_df/build.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/q04_get_match_specific_df/build.py b/q04_get_match_specific_df/build.py index 37ec96a..8bfe30b 100644 --- a/q04_get_match_specific_df/build.py +++ b/q04_get_match_specific_df/build.py @@ -1,7 +1,15 @@ -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") +def read_csv_data_to_df(path) : + df=pd.read_csv(path) + data=pd.DataFrame(df) + return data +def get_match_specific_df(match_code): + datas=read_csv_data_to_df('data/ipl_dataset.csv'); + output=datas.loc[(datas['match_code']==match_code)] + #print(output) + return output + +print(get_match_specific_df(598057)) -# Solution From 1982e9aca4b0d899ba936ff7f7d1940a1ec4e702 Mon Sep 17 00:00:00 2001 From: savans7 Date: Sun, 16 Sep 2018 03:52:53 +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..d08151e 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 +import pandas as pd + +def read_csv_data_to_df(path) : + df=pd.read_csv(path) + data=pd.DataFrame(df) + return data + +def create_bowler_filter(name): + datas=read_csv_data_to_df('data/ipl_dataset.csv'); + output=(datas['bowler']==name) + #print(output) + return output + +print(create_bowler_filter('I Sharma')) -# You have been given dataset already in 'ipl_df'. -ipl_df = read_csv_data_to_df("./data/ipl_dataset.csv") -# Solution From 40e1777ccadefc0c5133534b65335d2a074f25ef Mon Sep 17 00:00:00 2001 From: savans7 Date: Sun, 16 Sep 2018 04:24:56 +0000 Subject: [PATCH 6/7] Done --- q06_get_match_innings_runs/build.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/q06_get_match_innings_runs/build.py b/q06_get_match_innings_runs/build.py index d938fc2..bfa97fe 100644 --- a/q06_get_match_innings_runs/build.py +++ b/q06_get_match_innings_runs/build.py @@ -1,11 +1,17 @@ -# 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") +def read_csv_data_to_df(path) : + df=pd.read_csv(path) + data=pd.DataFrame(df) + return data -# Solution +def get_match_innings_runs(): + datas=read_csv_data_to_df('data/ipl_dataset.csv'); + output=datas.groupby('inning').sum()['runs'] + # print(output) + return output.sum() +print(get_match_innings_runs()) From 3893c05b484432e5f232033914e47e9f017cda6c Mon Sep 17 00:00:00 2001 From: savans7 Date: Sun, 16 Sep 2018 05:37:33 +0000 Subject: [PATCH 7/7] Done --- q07_get_run_counts_by_match/build.py | 24 +++++++++++++++++++----- 1 file changed, 19 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..42a4637 100644 --- a/q07_get_run_counts_by_match/build.py +++ b/q07_get_run_counts_by_match/build.py @@ -1,7 +1,21 @@ -# Default Imports -from greyatomlib.pandas_project.q01_read_csv_data_to_df.build import read_csv_data_to_df +import pandas as pd + +def read_csv_data_to_df(path) : + df=pd.read_csv(path,index_col=['match_code', 'runs'], + usecols=['match_code', 'runs']) + data=pd.DataFrame(df) + return data + +def get_runs_counts_by_match(): + datas=read_csv_data_to_df('data/ipl_dataset.csv'); + #output=datas['runs'] + #output2=datas['match_code'] + # data1=pd.DataFrame(columns=datas['runs'],index=datas['match_code']) + table = pd.pivot_table(datas, index=['match_code'],columns=['runs'],aggfunc=len) + #print(table) + return table + +print(get_runs_counts_by_match()) + -# You have been give the dataset already in 'ipl_df'. -ipl_df = read_csv_data_to_df("./data/ipl_dataset.csv") -# Solution