Skip to content

Commit Live PR #242

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 9 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
7 changes: 7 additions & 0 deletions q01_zeros_array/build.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
# %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), dtype=float)
return zeros_array



14 changes: 14 additions & 0 deletions q02_zeros_reshaped/build.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# %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

def array_reshaped_zeros():

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


array_reshaped_zeros()



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

# Enter solution here
# Enter solution here

def create_3d_array():

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



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

# Enter code here
def read_csv_data_to_ndarray(path, dt=np.float64):

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

return arr

read_csv_data_to_ndarray(path)


# Enter code here
19 changes: 18 additions & 1 deletion q05_read_csv_data/build.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,21 @@
# %load q05_read_csv_data/build.py
# Default imports

import numpy as np

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

def read_ipl_data_csv(path, dtype=np.float64):

arr = np.genfromtxt(path, delimiter=',', dtype = dtype , skip_header=1)
ipl_matches_array = arr[:,:].astype('|S50')
print(type(ipl_matches_array))
return ipl_matches_array

read_ipl_data_csv(path, dtype=np.float64)






12 changes: 12 additions & 0 deletions q06_get_unique_matches_count/build.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# %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():

arr = read_ipl_data_csv(path, '|S100')
arr = arr[:,0:1]
return np.unique(arr).size

get_unique_matches_count()


14 changes: 13 additions & 1 deletion q07_get_unique_teams_set/build.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# %load q07_get_unique_teams_set/build.py
# Default imports
import numpy as np
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'

# Enter Code Here
def get_unique_teams_set():

ipl_df = read_ipl_data_csv(path,dtype = 'S50')
ipl_new = ipl_df[:,[3,4]]
ipl_unique = set(np.unique(ipl_new))
return ipl_unique

# ipl_df


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():
ipl_df = read_ipl_data_csv(path,dtype = 'S50')
ipl_new = ipl_df[:,17].astype(int)
ipl_sum = np.sum(ipl_new)
return ipl_sum