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
7 changes: 7 additions & 0 deletions q01_zeros_array/build.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
# %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((3,4,2))
return zeros_array
array_zeros()

# Your solution




10 changes: 10 additions & 0 deletions q02_zeros_reshaped/build.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# %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((3,4,2))
print(zeros_array)
zeros_array_reshaped = zeros_array.reshape(2,3,4)
return zeros_array_reshaped
array_reshaped_zeros()



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

# Enter solution here
# Enter solution here
def create_3d_array():
arr=np.zeros((3,3,3))
print(arr)
print(len(arr))
N=1
for dim in np.shape(arr): N *= dim
print(N)
arr2=np.arange(0,N)
print(arr2)
arr2=arr2.reshape(3,3,3)
return arr2
create_3d_array()
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'
def read_csv_data_to_ndarray(path, dtype=np.float64):
array = np.genfromtxt(path, delimiter=',', dtype=dtype, skip_header=1)
print(array)
return array


# Enter code here


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



# Enter code here
10 changes: 9 additions & 1 deletion q06_get_unique_matches_count/build.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# %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():
ipl_matches_array = read_ipl_data_csv('data/ipl_matches_small.csv', dtype='|S50')
return len(set(ipl_matches_array[:,0]))
get_unique_matches_count()

# Enter Code Here


13 changes: 11 additions & 2 deletions q07_get_unique_teams_set/build.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# %load q07_get_unique_teams_set/build.py
# Default imports
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():
ipl_matches_array = read_ipl_data_csv('data/ipl_matches_small.csv', dtype='|S50')
team1 = set(ipl_matches_array[:,3])
team2 = set(ipl_matches_array[:,4])
teams = team1.union(team2)
return teams
get_unique_teams_set()
# Enter Code Here


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

# Enter Code Here
# Enter Code Here
def get_total_extras():
ipl_matches_array = read_ipl_data_csv('data/ipl_matches_small.csv', dtype='int')
return sum(ipl_matches_array[:,-6])
get_total_extras()