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
5 changes: 4 additions & 1 deletion q01_zeros_array/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,8 @@
import numpy as np

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


#print array_zeros()
7 changes: 7 additions & 0 deletions q02_zeros_reshaped/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,10 @@
from greyatomlib.python_intermediate.q01_zeros_array.build import array_zeros

# Write your code
def array_reshaped_zeros():
az = array_zeros()
ay = np.reshape(az,newshape=(2,3,4))
#print ay
#print(type(ay))
return ay
#print array_reshaped_zeros()
7 changes: 6 additions & 1 deletion q03_create_3d_array/build.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
# Default Imports
import numpy as np

# Enter solution here
# Enter solution here
def create_3d_array():
N = 27
arr = np.arange(0,N).reshape(3,3,3)
return arr
#print create_3d_array()
6 changes: 5 additions & 1 deletion q04_read_csv_data_to_ndarray/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,8 @@
import numpy as np
path = "./data/ipl_matches_small.csv"

# Enter code here
# Enter code here
def read_csv_data_to_ndarray(path,dtype=np.float64):
narr = np.genfromtxt(path, delimiter=",", dtype = dtype, skip_header=1)
return narr
#print read_csv_data_to_ndarray(path)
7 changes: 6 additions & 1 deletion q05_read_csv_data/build.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
# Default imports
import numpy as np

# Enter code here
# 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, delimiter=",", skip_header=1)
return ipl_matches_array
#print read_ipl_data_csv(path)
7 changes: 6 additions & 1 deletion q06_get_unique_matches_count/build.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# 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'

ipl_matches_array = {}
# Enter Code Here
def get_unique_matches_count():
ipl_matches_array = len(read_ipl_data_csv(path,dtype='|S50')[0,0])
return ipl_matches_array
print get_unique_matches_count()
10 changes: 9 additions & 1 deletion q07_get_unique_teams_set/build.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Default imports
from greyatomlib.python_intermediate.q05_read_csv_data.build import read_ipl_data_csv
path = "data/ipl_matches_small.csv"

import numpy as np
# Enter Code Here
def get_unique_teams_set():
ipl_matches_array = np.genfromtxt(path,delimiter=',',dtype='|S50',skip_header=1)
team1 = np.unique(ipl_matches_array[:,3])
team2 = np.unique(ipl_matches_array[:,4])
result = set(np.union1d(team1,team2))

return result
#print get_unique_teams_set()
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 @@
# Default Imports
from greyatomlib.python_intermediate.q05_read_csv_data.build import read_ipl_data_csv
import numpy as np

path = 'data/ipl_matches_small.csv'

# Enter Code Here
# Enter Code Here
def get_total_extras():
ipl_matches_array = np.genfromtxt(path,delimiter=',',dtype='|S50',skip_header=1)
extra_runs_array = ipl_matches_array[0:,17].astype(np.int16)
sum_of_runs = extra_runs_array.sum()
return sum_of_runs
print get_total_extras()