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
6 changes: 6 additions & 0 deletions q01_zeros_array/build.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
# %load q01_zeros_array/build.py
# Default Imports
import sys, os
sys.path.append(os.path.join(os.path.dirname(os.curdir), '..' ))
import numpy as np

# Your solution
def array_zeros():
zeros_array = np.zeros((3,4,2))

return zeros_array

zeros_array = array_zeros()

8 changes: 7 additions & 1 deletion q02_zeros_reshaped/build.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# %load q02_zeros_reshaped/build.py
# Default imports
import numpy as np
from greyatomlib.python_intermediate.q01_zeros_array.build import array_zeros

# Write your code
def array_reshaped_zeros():
a = array_zeros()
zeros_array_reshaped = np.reshape(a,(2,3,4))
return zeros_array_reshaped


11 changes: 9 additions & 2 deletions q03_create_3d_array/build.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
# Default Imports
import numpy as np

# Enter solution here
def create_3d_array():
N = 28
arr = np.arange(0,N-1)
print(type(arr))
new_arr = np.reshape(arr,(3,3,3))

return new_arr


12 changes: 10 additions & 2 deletions q04_read_csv_data_to_ndarray/build.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# %load q04_read_csv_data_to_ndarray/build.py
# Default Imports
import numpy as np
path = "./data/ipl_matches_small.csv"
path = './data/ipl_matches_small.csv'
# Enter code here
def read_csv_data_to_ndarray(path,dtype=np.float64):
m1 = np.genfromtxt(path,dtype=dtype,skip_header=1,delimiter=',')
return m1



read_csv_data_to_ndarray(path,'|S100')

# Enter code here
10 changes: 9 additions & 1 deletion q05_read_csv_data/build.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
# %load q05_read_csv_data/build.py
# Default imports
import numpy as np
# Enter code here
path = './data/ipl_matches_small.csv'
def read_ipl_data_csv(path,dtype='|S50'):
ipl_matches_array = np.genfromtxt(path,dtype=dtype,skip_header=1,delimiter=',')
#print(type(ipl_matches_array))
return ipl_matches_array

ipl_matches_array = read_ipl_data_csv(path)

# Enter code here
11 changes: 10 additions & 1 deletion q06_get_unique_matches_count/build.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# %load q06_get_unique_matches_count/build.py
# Default imports
import numpy as np
from greyatomlib.python_intermediate.q05_read_csv_data.build import read_ipl_data_csv
path = 'data/ipl_matches_small.csv'

# Enter Code Here
def get_unique_matches_count():
m = np.genfromtxt(path,dtype='|S50',skip_header=1,delimiter=',')
match_code = m[0:,0].astype(np.int64)
ipl_match_array = len(set(match_code))

return ipl_match_array


15 changes: 13 additions & 2 deletions q07_get_unique_teams_set/build.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# %load q07_get_unique_teams_set/build.py
# Default imports
import numpy as np
from greyatomlib.python_intermediate.q05_read_csv_data.build import read_ipl_data_csv
path = "data/ipl_matches_small.csv"
path = 'data/ipl_matches_small.csv'

def get_unique_teams_set():
m = read_ipl_data_csv(path,'|S50') #Called read_ipl_data function
team1 = (m[0:,3]) #extracted data from team 1 col & stored
team2 = (m[0:,4]) #extracted data from team 2 col & stored

#teams = team1 | team2 #union alternative
teams = np.union1d(team1,team2) #union of the set
return set(teams) #return set


# Enter Code Here
9 changes: 7 additions & 2 deletions q08_get_total_extras/build.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
# %load q08_get_total_extras/build.py
# Default Imports
from greyatomlib.python_intermediate.q05_read_csv_data.build import read_ipl_data_csv
import numpy as np

# Enter Code Here
path = 'data/ipl_matches_small.csv'
def get_total_extras():
m = read_ipl_data_csv(path,'|S50')
extras = sum(m[0:,17].astype(np.int16))

return extras

# Enter Code Here