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
5 changes: 4 additions & 1 deletion q01_zeros_array/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,8 @@
import numpy as np

# Your solution
def array_zeros():
zeros_array = np.zeros((3,4,2))
return zeros_array


print array_zeros()
6 changes: 6 additions & 0 deletions q02_zeros_reshaped/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,9 @@
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

print (array_reshaped_zeros())
8 changes: 7 additions & 1 deletion q03_create_3d_array/build.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
# Default Imports
import numpy as np

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

print create_3d_array()
8 changes: 7 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,10 @@
import numpy as np
path = "./data/ipl_matches_small.csv"

# Enter code here
# Enter code here
dtype = np.float64
def read_csv_data_to_ndarray(path,dtype):
array = np.genfromtxt(path, dtype=dtype, skip_header=1, delimiter=",")
return array

print (read_csv_data_to_ndarray(path,dtype))
6 changes: 5 additions & 1 deletion q05_read_csv_data/build.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# Default imports
import numpy as np

# Enter code here
# Enter code here
dtype='|S20'
def read_ipl_data_csv(path, dtype):
ipl_matches_array = np.genfromtxt(path, dtype=dtype, skip_header=1, delimiter=",")
return ipl_matches_array
11 changes: 11 additions & 0 deletions q06_get_unique_matches_count/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,14 @@
path = 'data/ipl_matches_small.csv'

# Enter Code Here
import numpy as np
dtype = '|S20'
def read_ipl_data_csv(path, dtype):
ipl_matches_array = np.genfromtxt(path, dtype=dtype, skip_header=1, delimiter=",")
return ipl_matches_array

def get_unique_matches_count():
ipl_matches_array = read_ipl_data_csv(path, dtype)
return len(set(ipl_matches_array[:,0]))

print get_unique_matches_count()
9 changes: 9 additions & 0 deletions q07_get_unique_teams_set/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,12 @@
path = "data/ipl_matches_small.csv"

# Enter Code Here
import numpy as np
dtype = '|S50'
def get_unique_teams_set():
var = read_ipl_data_csv(path,dtype)
team1 = set(var[:,3])
team2 = set(var[:,4])
return team1.union(team2)

print (get_unique_teams_set())
6 changes: 5 additions & 1 deletion q08_get_total_extras/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,8 @@

path = 'data/ipl_matches_small.csv'

# Enter Code Here
# Enter Code Here
dtype = np.int
def get_total_extras():
var = read_ipl_data_csv(path, dtype)
return sum(var[:,17])