Skip to content

Commit Live PR #245

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: 9 additions & 1 deletion q01_zeros_array/build.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
# %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





15 changes: 14 additions & 1 deletion q02_zeros_reshaped/build.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# %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
import sys, os
sys.path.append(os.path.join(os.path.dirname(os.curdir), '..' ))
import numpy as np

def array_reshaped_zeros():

zeros_array =np.zeros((3,4,2))
zeros_array_reshaped=np.reshape(zeros_array,(2,3,4))

return zeros_array_reshaped



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

# Enter solution here

def create_3d_array():
a=np.arange(0,27)
a=a.reshape(3,3,3)
return a





11 changes: 9 additions & 2 deletions q04_read_csv_data_to_ndarray/build.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# %load q04_read_csv_data_to_ndarray/build.py
# Default Imports
import numpy as np
path = "./data/ipl_matches_small.csv"
import csv
path = './data/ipl_matches_small.csv'



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

# Enter code here
10 changes: 9 additions & 1 deletion q05_read_csv_data/build.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
# %load q05_read_csv_data/build.py
# Default imports
import numpy as np
import csv
path = './data/ipl_matches_small.csv'

def read_ipl_data_csv(path,dtype='float64'):
ipl_matches_array=np.genfromtxt(path,dtype=dtype,delimiter=',',skip_header=1)
return ipl_matches_array
read_ipl_data_csv('./data/ipl_matches_small.csv')


# Enter code here
17 changes: 16 additions & 1 deletion q06_get_unique_matches_count/build.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
# %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
import csv
path = 'data/ipl_matches_small.csv'

# Enter Code Here
def get_unique_matches_count():
with open(path,'r') as f:
reader=csv.reader(f, delimiter=',')
header=next(reader)
data=list(reader)
arr=np.array(data)
ar2=arr[0:,0:1]
ar3=np.unique(ar2)
ipl_matches_array=np.size(ar3)
return ipl_matches_array
get_unique_matches_count()


20 changes: 18 additions & 2 deletions q07_get_unique_teams_set/build.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
# %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
import csv
path = 'data/ipl_matches_small.csv'

def get_unique_teams_set():
with open(path,'r') as f:
reader=csv.reader(f, delimiter=',')
header=next(reader)
data=list(reader)
ar1=np.array(data)
team1=set(ar1[:,3].astype('|S50'))
team2=set(ar1[:,4].astype('|S50'))
unio=team1.union(team2)
return unio

get_unique_teams_set()


# Enter Code Here
16 changes: 15 additions & 1 deletion q08_get_total_extras/build.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,21 @@
# %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
import csv

path = 'data/ipl_matches_small.csv'

# Enter Code Here
def get_total_extras():
with open(path,'r') as f:
reader=csv.reader(f, delimiter=',')
header=next(reader)
data=list(reader)
arr=np.array(data)
extras=np.hstack(arr[0:,17:18])
arr=np.array(extras, dtype=np.int32)
data=list(arr)
return np.sum(data)
get_total_extras()