Skip to content
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
10 changes: 9 additions & 1 deletion q01_read_csv_data_to_df/build.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
# %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)

df = read_csv_data_to_df(path)
df
df.shape


10 changes: 9 additions & 1 deletion q02_get_unique_values/build.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
# %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()

venues = get_unique_venues()
len(venues)


12 changes: 11 additions & 1 deletion q04_get_match_specific_df/build.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
# %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(match_code):
return ipl_df.loc[ipl_df['match_code'].isin([match_code])]

match_code = 598057
expected_shape = (241,24)
actual_shape = get_match_specific_df(match_code).shape
actual_shape



9 changes: 8 additions & 1 deletion q05_create_bowler_filter/build.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
# %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')

# Solution
def create_bowler_filter(bowler):
return ipl_df['bowler'] == bowler
bowler = 'I Sharma'
create_bowler_filter(bowler).sum()


13 changes: 12 additions & 1 deletion q06_get_match_innings_runs/build.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
# %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
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')

d = {'match_code': [], 'inning': [], 'runs': []}
df = pd.DataFrame(data=d)

df['match_code'] = ipl_df['match_code'].unique()

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

get_match_innings_runs().sum()



Expand Down