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
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
# %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


8 changes: 7 additions & 1 deletion q02_get_unique_values/build.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
#%load q02_get_unique_values/build.py
# %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():
venues = ipl_df['venue'].unique()
return venues

12 changes: 11 additions & 1 deletion q03_get_run_counts/build.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
#%load q03_get_run_counts/build.py
# %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

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")
ipl_df = read_csv_data_to_df('./data/ipl_dataset.csv')

# Solution
l=[]
# Solution
def get_run_counts():
l=ipl_df['runs'].value_counts()
return pd.Series(l)
get_run_counts()


12 changes: 10 additions & 2 deletions q04_get_match_specific_df/build.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
#%load q04_get_match_specific_df/build.py
# %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')
(ipl_df['match_code'])
# Solution
def get_match_specific_df(mc):
df=ipl_df[(ipl_df['match_code']==mc)]
return df
get_match_specific_df(598057)



11 changes: 9 additions & 2 deletions 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
# %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')
import pandas as pd
# Solution
def create_bowler_filter(b):
a=pd.Series(ipl_df['bowler']==b)
return a
create_bowler_filter('I Sharma')

20 changes: 19 additions & 1 deletion q06_get_match_innings_runs/build.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,29 @@
#%load q06_get_match_innings_runs/build.py# %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')

import numpy as np
# Solution
def get_match_innings_runs():
a=ipl_df.groupby(by=['match_code','inning']).agg(np.sum)
return a[['runs']]
get_match_innings_runs()

# %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')

import numpy as np
# Solution
def get_match_innings_runs():
a=ipl_df.groupby(by=['match_code','inning']).agg(np.sum)
return a[['runs']]
get_match_innings_runs()


12 changes: 11 additions & 1 deletion q07_get_run_counts_by_match/build.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
#%load q07_get_run_counts_by_match/build.py
# %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

# 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
import numpy as np
r=ipl_df['runs'].unique()
def get_runs_counts_by_match():
a=ipl_df.pivot_table(index='match_code',columns='runs',aggfunc='count')
return a['batsman']
get_runs_counts_by_match()