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: 8 additions & 0 deletions q01_zeros_array/build.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
# %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

def array_zeros():

zeros_array=np.zeros(shape=(3,4,2))

return zeros_array

# Your solution



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

def array_reshaped_zeros():
zeros_array_reshaped=array_zeros()
print(zeros_array_reshaped)
return(zeros_array_reshaped.reshape(2,3,4))

# Write your code


8 changes: 7 additions & 1 deletion q03_create_3d_array/build.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
# %load q03_create_3d_array/build.py
# Default Imports
import numpy as np

# Enter solution here
def create_3d_array():
matrix=np.arange(0,27).reshape(3,3,3)
return(matrix)

# Enter solution here

10 changes: 8 additions & 2 deletions q04_read_csv_data_to_ndarray/build.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# %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'

def read_csv_data_to_ndarray(path,dtypearg):
numpyarray = np.genfromtxt(path, dtype=dtypearg, skip_header=1,delimiter=',')
return numpyarray

# Enter code here

# Enter code here
9 changes: 8 additions & 1 deletion q05_read_csv_data/build.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
# %load q05_read_csv_data/build.py
# Default imports
import numpy as np

# Enter code here
def read_ipl_data_csv(path,dtype):
ipl_matches_array=np.genfromtxt(path,dtype=dtype,delimiter=',',skip_header=1)
#print(type(ipl_matches_array))
return(ipl_matches_array)
#read_ipl_data_csv('data/ipl_matches_small.csv','|S50')
# Enter code here

13 changes: 13 additions & 0 deletions q06_get_unique_matches_count/build.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# %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'

def get_unique_matches_count():
temp=[]
ipl_data=np.genfromtxt(path,delimiter=',',dtype='|S50',skip_header=1)
print(np.unique(ipl_data[0][0]))
for i in ipl_data:
#print((str(i[0])))
temp.append(str(i[0]))
return(len(np.unique(temp)))
#ipl_matches_array=
# Enter Code Here


18 changes: 17 additions & 1 deletion q07_get_unique_teams_set/build.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
# %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'

# Enter Code Here
def get_unique_teams_set():
team1=[]
team2=[]
teams=[]
data=read_ipl_data_csv(path,'|S50')
# print(data)
for i in data:
team1.append(i[3])
team2.append(i[4])
#print(type(np.unique(team1)))
teams=list(np.unique(team1))+list(np.unique(team2))
return(set(teams))
#get_unique_teams_set()

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

path = 'data/ipl_matches_small.csv'
array=np.array(0)

def get_total_extras():
data=read_ipl_data_csv(path,'int32')
x=np.array(data[0:,-6])


return(np.sum(x))
get_total_extras()
# Enter Code Here

# Enter Code Here