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
12 changes: 12 additions & 0 deletions q01_zeros_array/build.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
# %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(shape=(3,4,2))
return zeros_array



var = array_zeros()
var





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

zeros_array = array_zeros()
def array_reshaped_zeros():
zeros_array_reshaped = zeros_array.reshape((2,3,4))
return zeros_array_reshaped
var = array_reshaped_zeros()
var.shape

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

# Enter solution here
# Enter solution here
def create_3d_array():

actual = [
[[0, 1, 2],
[3, 4, 5],
[6, 7, 8]],

[[9, 10, 11],
[12, 13, 14],
[15, 16, 17]],

[[18, 19, 20],
[21, 22, 23],
[24, 25, 26]]
]
var = np.array(actual)
#N = var.size
N = np.count_nonzero(var)
array2 = np.arange(N-1)
var.reshape((3,3,3))
return var
create_3d_array()




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

path = './data/ipl_matches_small.csv'
input_dtype = '|S100'
# Enter code here
def read_csv_data_to_ndarray(path,input_dtype):
my_data = genfromtxt(path, dtype = input_dtype,delimiter=',',skip_header=1)
np.array(my_data)
return my_data
ipl_array = read_csv_data_to_ndarray('data/ipl_matches_small.csv', input_dtype)

ipl_array


# Enter code here
16 changes: 15 additions & 1 deletion q05_read_csv_data/build.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
# %load q05_read_csv_data/build.py
# Default imports
import numpy as np
from numpy import genfromtxt

# Enter code here
path = './data/ipl_matches_small.csv'
input_dtype = '|S50'
def read_ipl_data_csv(path,dtype):
ipl_matches_array = genfromtxt(path, dtype = dtype,delimiter=',',skip_header=1)
np.array(ipl_matches_array)
return ipl_matches_array

ipl_matches_array = read_ipl_data_csv('data/ipl_matches_small.csv',input_dtype)

ipl_matches_array


# Enter code here
20 changes: 20 additions & 0 deletions q06_get_unique_matches_count/build.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
# %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
from numpy import genfromtxt
import pandas as pd
path = 'data/ipl_matches_small.csv'

# Enter Code Here

matches = pd.read_csv('data/ipl_matches_small.csv')
#genfromtxt(path,delimiter=',',skip_header=1)
matches.head()
type(matches)
temp = matches['match_code'].nunique()
temp
def get_unique_matches_count():
# data = genfromtxt(path,delimiter=',',skip_header=1)
# ipl_matches_array = np.unique(data,return_counts = True)
ipl_matches_array = matches['match_code'].nunique()
return ipl_matches_array
get_unique_matches_count()



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
import pandas as pd

path = 'data/ipl_matches_small.csv'

# Enter Code Here
# Enter Code Here
matches = pd.read_csv(path)
matches['extras'].sum()
def get_total_extras ():
extras = matches['extras'].sum()
return extras
get_total_extras()