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: 4 additions & 2 deletions q01_zeros_array/build.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# %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
6 changes: 6 additions & 0 deletions q02_zeros_reshaped/build.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# %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
initial_array = array_zeros()

def array_reshaped_zeros():
zeros_array_reshaped = initial_array.reshape(2,3,4)
return zeros_array_reshaped
5 changes: 4 additions & 1 deletion q03_create_3d_array/build.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# Default Imports
import numpy as np

# Enter solution here
# Enter solution here

def create_3d_array():
return np.arange(27).reshape(3,3,3)
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, input_dtype):
iplarray = np.genfromtxt(path,input_dtype, delimiter=',', skip_header = 1)
return iplarray
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 @@
# Default imports
import numpy as np

# Enter code here
# Enter code here

# Enter code here

def read_ipl_data_csv(path,dtype='|S50'):
ipl_matches_array=np.genfromtxt(path,dtype='|S50',delimiter=',', skip_header=1)
return ipl_matches_array
8 changes: 8 additions & 0 deletions q06_get_unique_matches_count/build.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# 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 = read_ipl_data_csv(path,dtype='|S50')
total_matches = ipl_matches_array[0:,0]
unique_count=np.unique(total_matches)
matches_count = len(unique_count)
return matches_count
14 changes: 14 additions & 0 deletions q07_get_unique_teams_set/build.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# 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_teams_set():
result = read_ipl_data_csv(path, dtype='|S50')
team1 = result[0:,3]
team1_final = np.unique(team1)
team1_set = set(team1_final)

team2 = result[0:,4]
team2_final = np.unique(team2)
team2_set = set(team2_final)

final_teams = team1_set | team2_set
return final_teams
8 changes: 7 additions & 1 deletion q08_get_total_extras/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,10 @@

path = 'data/ipl_matches_small.csv'

# Enter Code Here
# Enter Code Here

def get_total_extras():
result = read_ipl_data_csv(path,dtype = '|S50')
extras = result[0:,17].astype(int)
total_extras = extras.sum(axis=0, dtype = np.int32)
return total_extras