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


array_zeros()
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():
zero_arrays = array_zeros()
zeros_array_reshaped = np.reshape(zero_arrays,(2,3,4))

return zeros_array_reshaped

# Write your code
array_reshaped_zeros()
11 changes: 10 additions & 1 deletion q03_create_3d_array/build.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
# %load q03_create_3d_array/build.py
# Default Imports
import numpy as np
def create_3d_array():
my_list=[]
my_list=range(27)
arr = np.array(my_list)
rarr = np.reshape(arr,(3, 3, 3))
return rarr

# Enter solution here
create_3d_array()

# Enter solution here
7 changes: 6 additions & 1 deletion q04_read_csv_data_to_ndarray/build.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# %load q04_read_csv_data_to_ndarray/build.py
# Default Imports
import numpy as np
path = "./data/ipl_matches_small.csv"

# Enter code here
def read_csv_data_to_ndarray(path,dtype=np.float64):

arr = np.genfromtxt(path,dtype=dtype,skip_header=1,delimiter=',')

return arr
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 @@
# %load q05_read_csv_data/build.py
# Default imports
import numpy as np
path = "./data/ipl_matches_small.csv"

# Enter code here
def read_ipl_data_csv(path,dtype=np.float32):
ipl_matches_array = np.genfromtxt(path,dtype=dtype,delimiter=',',skip_header=1)
return ipl_matches_array.astype('|S50')
# Enter code here
10 changes: 8 additions & 2 deletions q06_get_unique_matches_count/build.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# %load q06_get_unique_matches_count/build.py
# Default imports
from greyatomlib.python_intermediate.q05_read_csv_data.build import read_ipl_data_csv
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():

ipl_matches_array = np.genfromtxt(path,dtype='|S50',delimiter=',',skip_header=1)
count=int(len(np.unique(ipl_matches_array[0:,0])))
return count
12 changes: 10 additions & 2 deletions q07_get_unique_teams_set/build.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# %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():
data = read_ipl_data_csv(path,dtype='|S50')
unique_team1 , team1_fre= np.unique(data[:,3],return_counts=True)
unique_team2 , team2_fre= np.unique(data[:,4],return_counts=True)
unique_teams={member for member in np.append(unique_team2,unique_team1)}

# Enter Code Here
return unique_teams
# Enter Code Here
11 changes: 8 additions & 3 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
#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
def get_total_extras():
ipl_matches_array = np.genfromtxt(path,dtype='|S50',delimiter=',')
# Enter Code Here
#np.unique(ipl_matches_array[1:1451,17])
get_total_extras=np.sum(ipl_matches_array[1:1452,17].astype(np.float),dtype = np.int,axis = None)
return get_total_extras