Skip to content

Commit Live PR #212

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion q01_read_csv_data_to_df/build.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
# %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
df = read_csv_data_to_df (path)
df.shape

11 changes: 10 additions & 1 deletion q02_get_unique_values/build.py
Original file line number Diff line number Diff line change
@@ -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')

#Solution
def get_unique_venues() :
uni = ipl_df['venue'].unique()
return uni
ipl_df.head()
ipl_df['venue'].unique()



11 changes: 10 additions & 1 deletion q03_get_run_counts/build.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
# %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() :
for x in ipl_df['runs']:
freq = ipl_df['runs'].value_counts()
return freq

#ipl_df['runs']
get_run_counts()


17 changes: 15 additions & 2 deletions q04_get_match_specific_df/build.py
Original file line number Diff line number Diff line change
@@ -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

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 get_match_specific_df(match_code):
s = pd.Series()
s = ipl_df.loc[ipl_df['match_code'] == match_code]
return s
type(ipl_df['match_code'])
ipl_df.loc[ipl_df['match_code'] == 392203]

get_match_specific_df(598057)





46 changes: 45 additions & 1 deletion q05_create_bowler_filter/build.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,51 @@
# %load q05_create_bowler_filter/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 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 (name):
for x in ipl_df['bowler']:
#s = pd.Series( index = list(x))
s = pd.Series(ipl_df['bowler'] == name)
#logical_results = str(s) == name
#logical_results_series = pd.Series(np.arange(0,8),index=logical_results)
#new = s[logical_results]
#return new
return s
#bow_array =pd.Series
#for x in ipl_df['bowler']:
#ipl_df['bowler'] == name
#bow_array = pd.Series(True)
# return bow_array
create_bowler_filter('I Sharma').shape

#if ipl_df['bowler'] == 'AB Dinda':
# boolean_value = True
#else:
# boolean_value = False


















9 changes: 7 additions & 2 deletions q06_get_match_innings_runs/build.py
Original file line number Diff line number Diff line change
@@ -1,11 +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')

# Solution
## Solution
def get_match_innings_runs():
result = ipl_df.groupby(['match_code','inning'])['runs'].sum()
return result



get_match_innings_runs()

15 changes: 13 additions & 2 deletions q07_get_run_counts_by_match/build.py
Original file line number Diff line number Diff line change
@@ -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():
runs_by_match = ipl_df.pivot_table(values='delivery', index='match_code', columns=['runs'],
aggfunc='count')
return runs_by_match
get_runs_counts_by_match()