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
10 changes: 7 additions & 3 deletions 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), '..' ))
# Your solution
import numpy as np
def array_zeros():
zeros_array = np.zeros((3,4,2),dtype=float)
print(zeros_array)

# Your solution
return zeros_array
array_zeros()


9 changes: 9 additions & 0 deletions q02_zeros_reshaped/build.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# %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():
zeros_array = np.zeros((2,3,4),dtype=float)
print(zeros_array)

return zeros_array
array_reshaped_zeros()


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

# Enter solution here
# Enter solution here
def create_3d_array():
N = 3*3*3
a = np.arange(0, N)
zeros_array = np.reshape(a,(3,3,3))
print(zeros_array)

return zeros_array
create_3d_array()



13 changes: 11 additions & 2 deletions q04_read_csv_data_to_ndarray/build.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# %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):
path1 = np.genfromtxt(path,dtype=dtype, skip_header = 1,delimiter=',')
return path1
read_csv_data_to_ndarray(path,dtype='|S20')




# Enter code here
11 changes: 10 additions & 1 deletion q05_read_csv_data/build.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
# %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.float64):
path1 = np.genfromtxt(path,dtype=dtype,skip_header = 1,delimiter=',')
print(path1.shape)
return path1
read_ipl_data_csv(path,dtype='|S50')


# Enter code here
10 changes: 10 additions & 0 deletions q06_get_unique_matches_count/build.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# %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():
ipl_matches_array = np.genfromtxt(path,dtype='|S20', skip_header = 1,delimiter=',')
matches = len(np.unique(ipl_matches_array [:,0]))
return matches
get_unique_matches_count()



14 changes: 13 additions & 1 deletion q07_get_unique_teams_set/build.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# %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():
ipl_matches_array = np.genfromtxt(path,dtype='|S50', skip_header = 1,delimiter=',')
team1 = np.unique(ipl_matches_array [:,3])
team2 = np.unique(ipl_matches_array [:,4])
teams = np.union1d(team1,team2)
teamsset = set(teams)
return teamsset
get_unique_teams_set()