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
9 changes: 8 additions & 1 deletion 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

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

array_zeros()




9 changes: 8 additions & 1 deletion 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 = np.zeros([3,4,2])
reshape = zeros.reshape([2,3,4])
return (reshape)
array_reshaped_zeros()


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

# Enter solution here
def create_3d_array():
vals = np.arange(0,27)
reshapedd = vals.reshape([3,3,3])
return reshapedd
create_3d_array()


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'

def read_csv_data_to_ndarray(path, dtype=np.float64):
return np.genfromtxt(path, dtype=dtype, delimiter=',', skip_header=1)

read_csv_data_to_ndarray(path)

# Enter code here
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 @@
# %load q05_read_csv_data/build.py
# Default imports
import numpy as np

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

12 changes: 11 additions & 1 deletion q06_get_unique_matches_count/build.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# %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 = np.genfromtxt(path, dtype=None, delimiter=',', skip_header=1,usecols=(0)) #read csv file
ipl_matches_array = np.unique(ipl_matches_array,return_counts=True) #find unique values
match_code, counts = ipl_matches_array #saperate unique values and their counts
#zipping = zip(match_code, counts) #zip those together. It is an unnecessary step.
zipping = np.array(counts)
return zipping.size


21 changes: 19 additions & 2 deletions q07_get_unique_teams_set/build.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
# %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'

def get_unique_teams_set():
ipl_matches_array = np.genfromtxt(path, dtype=None, delimiter=',', skip_header=1,usecols=(3)) #read csv file
ipl_matches_array = np.unique(ipl_matches_array,return_counts=True) #find unique values
team1 = ipl_matches_array #saperate unique values and their counts
set1 = set(team1[0])
#print set1
#print ''
ipl_matches_array = np.genfromtxt(path, dtype=None, delimiter=',', skip_header=1,usecols=(4)) #read csv file
ipl_matches_array = np.unique(ipl_matches_array,return_counts=True) #find unique values
team2 = ipl_matches_array #saperate unique values and their counts
set2 = set(team2[0])
#print set2

setPrime = set1.union(set2)
return setPrime

# Enter Code Here
6 changes: 5 additions & 1 deletion q08_get_total_extras/build.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
# %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
def get_total_extras():
extras = np.genfromtxt(path, dtype=None, delimiter=',', skip_header=1,usecols=(17)) #read csv file
return extras.sum()