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




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


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

# Enter solution here
# Enter solution here
def create_3d_array():
arr_nd=np.arange(0,27).reshape(3,3,3)
return arr_nd

9 changes: 7 additions & 2 deletions 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"
path = './data/ipl_matches_small.csv'
dtype1=np.float64
# Enter code here
def read_csv_data_to_ndarray(path=path,dtype1=dtype1):
arr_csv=np.genfromtxt(path,dtype=dtype1, skip_header=1, delimiter=',')
return arr_csv

# Enter code here
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

# Enter code here
# Enter code here
def read_ipl_data_csv(path='./data/ipl_matches_small.csv', dtype=np.float):
ipl_matches_array=np.genfromtxt(path,dtype='|S50', skip_header=1, delimiter=',')
return ipl_matches_array

4 changes: 2 additions & 2 deletions q05_read_csv_data/tests/test_q05_read_ipl_data_csv.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import sys, os
import sys, os
sys.path.append(os.path.join(os.path.dirname(os.curdir)))

from unittest import TestCase
Expand All @@ -12,4 +12,4 @@ def test_read_ipl_data_return_shape(self):
self.assertTrue(ipl_matches_array.shape == (1451, 23), "The Expected shape does not match the return shape")

def test_read_ipl_data_return_dtype(self):
self.assertTrue(ipl_matches_array.dtype == '|S50', "The Expectd dtype does not match the return dtype")
self.assertTrue(ipl_matches_array.dtype == '|S50', "The Expectd dtype does not match the return dtype")
9 changes: 9 additions & 0 deletions q06_get_unique_matches_count/build.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# %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_1=np.genfromtxt(path,dtype='|S50', skip_header=1, delimiter=',')
ipl_matches_array_2=np.unique(ipl_matches_array_1[:,0])
ipl_matches_array=np.count_nonzero(ipl_matches_array_2)
return ipl_matches_array


11 changes: 10 additions & 1 deletion 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
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():
team_data=read_ipl_data_csv('./data/ipl_matches_small.csv','|S50')
team1=np.unique(team_data[:,3])
team2=np.unique(team_data[:,4])
team_union=np.union1d(team1,team2)
return set(team_union)

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
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():
data=np.genfromtxt('data/ipl_matches_small.csv',dtype=np.int,skip_header=1,delimiter=',')
total=data[:,17].sum()
return total