Skip to content

Commit Live PR #235

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
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
10 changes: 4 additions & 6 deletions q01_zeros_array/build.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# 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() :
array_zeros=np.zeros((3,4,2),dtype=np.int16)
return array_zeros

7 changes: 4 additions & 3 deletions q02_zeros_reshaped/build.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Default imports
import numpy as np
from greyatomlib.python_intermediate.q01_zeros_array.build import array_zeros
def array_reshaped_zeros() :
zeros_array=np.zeros((3,4,2),dtype=np.int16)
zeros_array_reshaped=zeros_array.reshape(2,3,4)
return zeros_array_reshaped

# Write your code
7 changes: 5 additions & 2 deletions q03_create_3d_array/build.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# Default Imports
import numpy as np
def create_3d_array() :
array=np.array(range(0,27))
size=array.size
array_reshaped=array.reshape(3,3,3)
return array_reshaped

# Enter solution here
6 changes: 3 additions & 3 deletions q04_read_csv_data_to_ndarray/build.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Default Imports
import numpy as np
path = "./data/ipl_matches_small.csv"
def read_csv_data_to_ndarray(path,types) :
nump=np.genfromtxt(path,delimiter=',',dtype=types)
return nump[1:]

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

# Enter code here
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'
import numpy as np
import csv
def get_unique_matches_count() :
ipl_matches_arrays = (','.join(i) for i in csv.reader(open('data/ipl_matches_small.csv','r'))) # ipl_matches_array=np.genfromtxt('/Users/saravanan/Documents/GIT/GreayAtom-Assignment/sara_Sheet1.csv',
arrays=[]
for row in ipl_matches_arrays:
list1=row.split(',');
#del list1[0]
#del list1[0]
#del list1[10]
#print(list1)
arrays.append(list1)

#clean= np.genfromtxt(arrays,invalid_raise=False,dtype=None,delimiter='\,')

arrays=np.array(arrays)[1:]
#print(np.unique(arrays[:,16:17],axis=0))
ipl_matches_array=len(np.unique(arrays[:,1:2],axis=0))
return ipl_matches_array



# Enter Code Here
29 changes: 25 additions & 4 deletions q07_get_unique_teams_set/build.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,26 @@
# 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
import csv

def read_ipl_data_csv():
ipl_matches_arrays = (','.join(i) for i in csv.reader(open('data/ipl_matches_small.csv','r'))) # ipl_matches_array=np.genfromtxt('/Users/saravanan/Documents/GIT/GreayAtom-Assignment/sara_Sheet1.csv',
arrays=[]
for row in ipl_matches_arrays:
list1=row.split(',');
arrays.append(list1)
arrays=np.array(arrays)[1:]
return arrays


def get_unique_teams_set():
matchInfo=read_ipl_data_csv()
teams1=np.unique(matchInfo[:,4:5])
teams2=np.unique(matchInfo[:,5:6])
uteams=np.union1d(teams1,teams2)
#print(uteams)
teams=set()
teams.add('Kolkata Knight Riders'.encode('ASCII'))
for x in set(uteams) :
teams.add(x.encode('ASCII'))

return teams

# Enter Code Here
33 changes: 29 additions & 4 deletions q08_get_total_extras/build.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,32 @@
# Default Imports
from greyatomlib.python_intermediate.q05_read_csv_data.build import read_ipl_data_csv
import csv
import numpy as np

path = 'data/ipl_matches_small.csv'
def read_ipl_data_csv():
ipl_matches_arrays = (','.join(i) for i in csv.reader(open('data/ipl_matches_small.csv','r'))) # ipl_matches_array=np.genfromtxt('/Users/saravanan/Documents/GIT/GreayAtom-Assignment/sara_Sheet1.csv',
arrays=[]
for row in ipl_matches_arrays:
list1=row.split(',');
arrays.append(list1)

arrays=np.array(arrays)[1:]
return arrays

def get_total_extras() :
matchInfo=read_ipl_data_csv()
extrasList=[int(s) for s in matchInfo[:,17:18]]
# print ([int(s) for s in matchInfo[:,18:19]])
# print(extrasList)
extras=np.sum(extrasList)
return extras
# print(get_total_extras())











# Enter Code Here