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: 3 additions & 3 deletions q01_zeros_array/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
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 np.array(zeros_array)
5 changes: 4 additions & 1 deletion q02_zeros_reshaped/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@
import numpy as np
from greyatomlib.python_intermediate.q01_zeros_array.build import array_zeros

# Write your code
def array_reshaped_zeros():
zeros_array_reshaped=array_zeros()
zeros_array_reshaped.resize((2,3,4))
return zeros_array_reshaped
6 changes: 5 additions & 1 deletion q03_create_3d_array/build.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# Default Imports
import numpy as np

# Enter solution here
def create_3d_array():
numbers= list(range(0,27))
my_array=np.array(numbers)
my_array.resize((3,3,3))
return my_array
4 changes: 3 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,6 @@
import numpy as np
path = "./data/ipl_matches_small.csv"

# Enter code here
def read_csv_data_to_ndarray(path,dtype=np.float64):
ipl_data=np.genfromtxt(path, delimiter=",",dtype=dtype,skip_header=1)
return ipl_data
4 changes: 3 additions & 1 deletion q05_read_csv_data/build.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# Default imports
import numpy as np

# Enter code here
def read_ipl_data_csv(path,dtype=np.float64):
ipl_matches_array=np.genfromtxt(path, delimiter=",",dtype=dtype,skip_header=1)
return ipl_matches_array
8 changes: 6 additions & 2 deletions q06_get_unique_matches_count/build.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# 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_match_array=read_ipl_data_csv(path,'|S50')
test=np.unique(ipl_match_array[:,0])
get_unique_matches_count=np.size(np.unique(ipl_match_array[:,0]))
return get_unique_matches_count
13 changes: 12 additions & 1 deletion q07_get_unique_teams_set/build.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# %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"

# Enter Code Here
def get_unique_teams_set():
team_set=set()
ipl_match_array=read_ipl_data_csv(path,'|S50')
team1=np.unique(ipl_match_array[:,3])
team2=ipl_match_array[:,4]
for elements in team1:
team_set.add(elements)
for elements in team2:
team_set.add(elements)
return team_set
8 changes: 7 additions & 1 deletion q08_get_total_extras/build.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
# %load q08_get_total_extras/build.py
# Default Imports
import numpy as np
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_match_array=read_ipl_data_csv(path,'|S50')
total_extras=np.sum(ipl_match_array[:,17].astype(np.int))
return total_extras