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

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

return zeros_array

print (array_zeros())
8 changes: 8 additions & 0 deletions q02_zeros_reshaped/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,11 @@
from greyatomlib.python_intermediate.q01_zeros_array.build import array_zeros

# Write your code
def array_reshaped_zeros():

arr1 = array_zeros()
zeros_array_reshaped = arr1.reshape(2,3,4)

return zeros_array_reshaped

print 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 @@
# Default Imports
import numpy as np

# Enter solution here
# Enter solution here
def create_3d_array():
n = 3**3

array1 = np.arange(n).reshape(3,3,3)

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

# Enter code here
# Enter code here
def read_csv_data_to_ndarray(link,data_type):
f1 = np.genfromtxt(link, delimiter=',', dtype=data_type,skip_header=1)
return f1

read_csv_data_to_ndarray(path,'|S20')
11 changes: 10 additions & 1 deletion q05_read_csv_data/build.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
# Default imports
import numpy as np
path = "./data/ipl_matches_small.csv"

# Enter code here
# Enter code here
def read_ipl_data_csv(filePath, dtype='|S50'):
ipl_matches_array = np.genfromtxt(filePath,dtype,delimiter=',',skip_header=1)
#
#print type(ipl_matches_array)
#print ipl_matches_array.shape
return ipl_matches_array

# Enter code here
11 changes: 10 additions & 1 deletion q06_get_unique_matches_count/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,13 @@
from greyatomlib.python_intermediate.q05_read_csv_data.build import read_ipl_data_csv
path = 'data/ipl_matches_small.csv'

# Enter Code Here
# Enter Code Here
import numpy as np

def get_unique_matches_count():
f1 = read_ipl_data_csv(path,dtype='|S50')
#print type(f1)
ipl_matches_array = np.unique(f1[:,0])
#print ipl_matches_array

return len(ipl_matches_array)
26 changes: 24 additions & 2 deletions q07_get_unique_teams_set/build.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,27 @@
# Default imports
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"
path = '/home/snmjack/Workspace/code/python_intermediate_project/data/ipl_matches_small.csv'
#/home/snmjack/.atom/.commit-live/code/python_intermediate_project/data
import numpy as np
# Enter Code Here

# Enter Code Here
def get_unique_teams_set():
#unique_teams = ()
data = read_ipl_data_csv(path,dtype='|S50')
#print data
team1 = set(data[:,3])
team2 = set(data[:,4])
#team1 = np.unique(data[:,3])
#print team1
#team2 = np.unique(data[:,4])
#print team2
#print type(team2)
#unique_teams = [team1] unioun [team2]
unique_teams = team1.union(team2)
#print unique_teams
#print type(unique_teams)

return unique_teams

#et_unique_teams_set()
12 changes: 11 additions & 1 deletion q08_get_total_extras/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,14 @@

path = 'data/ipl_matches_small.csv'

# Enter Code Here
# Enter Code Here

def get_total_extras():

data = read_ipl_data_csv(path, dtype='|S50')
extra = data[:,17].astype(np.int16)
extras = extra.sum(axis=0)
#print extras
#print data

return extras