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

#
import numpy as np
def array_zeros():
#import numpy as np

arr=np.zeros((3,4,2))
return arr
#print(arr)

# Your solution


12 changes: 9 additions & 3 deletions q02_zeros_reshaped/build.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Default imports
#%load q02_zeros_reshaped/build.py
import numpy as np
from greyatomlib.python_intermediate.q01_zeros_array.build import array_zeros
def array_reshaped_zeros():

arr=np.zeros((3,4,2))
zeros_array_reshaped=arr.reshape((2,3,4))
#print(arr1)
return zeros_array_reshaped



# Write your code
12 changes: 10 additions & 2 deletions q03_create_3d_array/build.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
# Default Imports
#%load q03_create_3d_array/build.py

import numpy as np

# Enter solution here
def create_3d_array() :


arr=np.arange(27).reshape(3,3,3)

return arr


21 changes: 18 additions & 3 deletions q04_read_csv_data_to_ndarray/build.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
# Default Imports
#%load q04_read_csv_data_to_ndarray/build.py

import numpy as np
path = "./data/ipl_matches_small.csv"

# Enter code here
path='./data/ipl_matches_small.csv'
dtype= '|S20'
def read_csv_data_to_ndarray(path,dtype):

arr=np.genfromtxt(path,delimiter=',',dtype=dtype,skip_header=1)
#print(type(arr))
#print(arr.dtype)


return arr

read_csv_data_to_ndarray(path,dtype)




16 changes: 14 additions & 2 deletions q05_read_csv_data/build.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
# Default imports
#%load q05_read_csv_data/build.py

import numpy as np

# Enter code here
path='./data/ipl_matches_small.csv'
dtype='|S50'

def read_ipl_data_csv(path,dtype):

ipl_matches_array=np.genfromtxt(path,delimiter=',',skip_header=1,dtype=dtype)

#print(ipl_matches_array)
return ipl_matches_array



25 changes: 21 additions & 4 deletions q06_get_unique_matches_count/build.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
# Default imports
from greyatomlib.python_intermediate.q05_read_csv_data.build import read_ipl_data_csv
path = 'data/ipl_matches_small.csv'
#%load q06_get_unique_matches_count/build.py

import numpy as np

path='./data/ipl_matches_small.csv'

def get_unique_matches_count():

ipl_matches_array=np.genfromtxt(path,delimiter=',',skip_header=1,dtype='|S20')
#print(ipl_matches_array)

nouniquecounts=np.unique(ipl_matches_array[:,0],axis=0)
nocounts=nouniquecounts.size


#print(noCounts.size)
return nocounts





# Enter Code Here
38 changes: 34 additions & 4 deletions q07_get_unique_teams_set/build.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,35 @@
# Default imports
from greyatomlib.python_intermediate.q05_read_csv_data.build import read_ipl_data_csv
path = "data/ipl_matches_small.csv"
#%load q07_get_unique_teams_set/build.py/

import numpy as np

path='./data/ipl_matches_small.csv'

def get_unique_teams_set():
arr=np.genfromtxt(path,delimiter=',',skip_header=1,dtype='|S25')

#team1=arr[:,2:]

team1=np.unique(arr[:,3],axis=0)
team2=np.unique(arr[:,4],axis=0)

uniqueteams=np.union1d(team1,team2)
#Team=team1.union(team2)
x=set(uniqueteams.flat)

#print(team1)
#print(team2)
#print(uniqueteams)
return (x)



get_unique_teams_set()









# Enter Code Here
18 changes: 14 additions & 4 deletions q08_get_total_extras/build.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
# Default Imports
from greyatomlib.python_intermediate.q05_read_csv_data.build import read_ipl_data_csv
#%load q08_get_total_extras/build.py

import numpy as np

path = 'data/ipl_matches_small.csv'
path='./data/ipl_matches_small.csv'

def get_total_extras():

arr=np.genfromtxt(path,delimiter=',',skip_header=1,dtype=int)
#arr
#print(sum(arr[:,17]))
ext=sum(arr[:,17])
return ext

get_total_extras()


# Enter Code Here