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

def array_zeros():
# Your solution
arrayresult=np.zeros((3,4,2))
return arrayresult




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():
Count=3*3*3
l1=list(range(0,Count,1))
arr1=np.array(l1)
arr2=arr1.reshape(3,3,3)
print(arr2.shape)
return arr2

12 changes: 10 additions & 2 deletions q04_read_csv_data_to_ndarray/build.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# %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 , dtype = np.float64):
result = np.genfromtxt(path,skip_header = 1 , delimiter = ',' , dtype= dtype)
return result
print(read_csv_data_to_ndarray(path))


# Enter code here
9 changes: 8 additions & 1 deletion q05_read_csv_data/build.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
# %load q05_read_csv_data/build.py
# Default imports
import numpy as np
path = './data/ipl_matches_small.csv'
def read_ipl_data_csv(path,dtype):
ipl_matches_array=np.genfromtxt(path,delimiter= ',',skip_header=1,dtype=dtype)
return(ipl_matches_array)
read_ipl_data_csv(path,'|S50')



# Enter code here
11 changes: 10 additions & 1 deletion q06_get_unique_matches_count/build.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# %load q06_get_unique_matches_count/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 pandas as pd

def get_unique_matches_count():
data2=pd.read_csv(path,delimiter=',',dtype='|S50')
ipl_matches_array=data2.iloc[:,0:1].nunique()
return(ipl_matches_array[0])
get_unique_matches_count()


# Enter Code Here
12 changes: 10 additions & 2 deletions q07_get_unique_teams_set/build.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# %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"
path = 'data/ipl_matches_small.csv'
import numpy as np
import pandas as pd

def get_unique_teams_set():
df=read_ipl_data_csv(path,dtype='|S50')
return(set(np.unique(df[:,3])).union(np.unique(df[:,4])))
get_unique_teams_set()


# Enter Code Here
11 changes: 9 additions & 2 deletions q08_get_total_extras/build.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
# %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'
path = './data/ipl_matches_small.csv'

# Enter Code Here
def get_total_extras():
array1=np.genfromtxt(path,delimiter=',')
result=np.sum(array1[:,17][~np.isnan(array1[:,17])])
return(np.int64(result))
get_total_extras()

# Enter Code Here