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
5 changes: 3 additions & 2 deletions q01_zeros_array/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
import numpy as np

# Your solution


def array_zeros():
zeros_array = np.zeros((3,4,2))
return zeros_array
3 changes: 3 additions & 0 deletions q02_zeros_reshaped/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@
from greyatomlib.python_intermediate.q01_zeros_array.build import array_zeros

# Write your code
def array_reshaped_zeros():
zeros = np.zeros((2,3,4))
return zeros
8 changes: 7 additions & 1 deletion q03_create_3d_array/build.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
# Default Imports
import numpy as np

# Enter solution here
# Enter solution here
def create_3d_array():
n = np.count_nonzero(np.ones((3,3,3)))
arr = np.arange(n)
arr = arr.reshape(3,3,3)
return arr
create_3d_array()
5 changes: 4 additions & 1 deletion q04_read_csv_data_to_ndarray/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@
import numpy as np
path = "./data/ipl_matches_small.csv"

# Enter code here
# Enter code here
def read_csv_data_to_ndarray(path,dtype=np.float64):
data = np.genfromtxt(path,dtype,delimiter=',',skip_header=True)
return data
8 changes: 7 additions & 1 deletion q05_read_csv_data/build.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
# Default imports
import numpy as np
path = "./data/ipl_matches_small.csv"

# Enter code here
# Enter code here
def read_ipl_data_csv(path,dtype='|S50'):
ipl_matches_array = np.genfromtxt(path,delimiter=',',dtype='|S50',skip_header=True)
return ipl_matches_array

read_ipl_data_csv(path)
9 changes: 7 additions & 2 deletions q06_get_unique_matches_count/build.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Default imports
from greyatomlib.python_intermediate.q05_read_csv_data.build import read_ipl_data_csv
path = 'data/ipl_matches_small.csv'

# Enter Code Here
import pandas as pd
# Enter Code Here
def get_unique_matches_count():
ipl_matches_array = pd.read_csv(path)
count = ipl_matches_array.groupby('match_code').size()
ipl_matches_array = count.count()
return ipl_matches_array
9 changes: 8 additions & 1 deletion q07_get_unique_teams_set/build.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Default imports
from greyatomlib.python_intermediate.q05_read_csv_data.build import read_ipl_data_csv
import pandas as pd
path = "data/ipl_matches_small.csv"

# Enter Code Here
# Enter Code Here
def get_unique_teams_set():
data = pd.read_csv(path,dtype='|S50')
team1 = set(data['team1'])
team2 = set(data['team2'])
teams = team1 | team2
return teams
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 @@
# 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
def get_total_extras():
data = pd.read_csv(path,delimiter=',')
a = data['extras']
sum1 = a.sum(axis=0)
extras = int(sum1)
return extras
get_total_extras()