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
18 changes: 10 additions & 8 deletions q01_zeros_array/build.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# Default Imports
import sys, os
sys.path.append(os.path.join(os.path.dirname(os.curdir), '..' ))
import numpy as np

# Your solution


# 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
18 changes: 15 additions & 3 deletions q02_zeros_reshaped/build.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# Default imports
# Default Imports
import sys, os
sys.path.append(os.path.join(os.path.dirname(os.curdir), '..' ))
import numpy as np
from greyatomlib.python_intermediate.q01_zeros_array.build import array_zeros

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

return zeros_array

def array_reshaped_zeros():
zeros_array_reshaped = array_zeros().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():
N=3*3*3
array_a = np.array((range(N)))
array_a = array_a.reshape((3,3,3))
return array_a
print create_3d_array()
8 changes: 6 additions & 2 deletions q04_read_csv_data_to_ndarray/build.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Default Imports
import numpy as np
path = "./data/ipl_matches_small.csv"

# Enter code here
import csv
# Enter code here
def read_csv_data_to_ndarray(path, dtype=np.float64):
file = np.genfromtxt(path, delimiter=',',skip_header=1,dtype=dtype)
x=np.array(file)
return x
14 changes: 10 additions & 4 deletions q05_read_csv_data/build.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
# Default imports
import numpy as np

# Enter code here
# %load q05_read_csv_data/build.py
# Default imports
import numpy as np
path = "./data/ipl_matches_small.csv"

# Enter code here
def read_ipl_data_csv(path,dtype=None):
ipl_matches_array=np.genfromtxt(path,delimiter=',',dtype='|S50',skip_header=1)
return ipl_matches_array
print read_ipl_data_csv(path,dtype=None)
21 changes: 16 additions & 5 deletions q06_get_unique_matches_count/build.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# Default imports
from greyatomlib.python_intermediate.q05_read_csv_data.build import read_ipl_data_csv
path = 'data/ipl_matches_small.csv'

# Enter Code Here
# %load q06_get_unique_matches_count/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_unique_matches_count():
data =read_ipl_data_csv(path,dtype='|S50')
Row = data[:len(data),0]
Matches=np.unique(Row)
ipl_matches_array=len(Matches)


return ipl_matches_array
print get_unique_matches_count()
21 changes: 16 additions & 5 deletions q07_get_unique_teams_set/build.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# Default imports
from greyatomlib.python_intermediate.q05_read_csv_data.build import read_ipl_data_csv
path = "data/ipl_matches_small.csv"

# Enter Code Here
# %load q07_get_unique_teams_set/build.py
# Default imports
from greyatomlib.python_intermediate.q05_read_csv_data.build import read_ipl_data_csv
path = "data/ipl_matches_small.csv"
import numpy as np

# Enter Code Here
def get_unique_teams_set():
actual_data = read_ipl_data_csv(path, dtype='|S50')
unique_team1 = np.unique(actual_data[:,3:4])
unique_team2 = np.unique(actual_data[:,4:5])
combined_unique = np.hstack((unique_team1,unique_team2))
totally_unique = set(combined_unique)
return totally_unique

print get_unique_teams_set()
11 changes: 10 additions & 1 deletion q08_get_total_extras/build.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
# %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 = read_ipl_data_csv(path,dtype=np.int16)
extras=data[:len(data),17:18]
sum1 = extras.sum()


return sum1
print get_total_extras()