Skip to content

Commit Live PR #216

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

Closed
wants to merge 8 commits into from
Closed
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
15 changes: 15 additions & 0 deletions q01_zeros_array/build.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,23 @@
# %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))
print(zeros_array)
return zeros_array



array_zeros()








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
def array_reshaped_zeros():
zeros_array=np.zeros((3,4,2))
zeros_array_reshaped=zeros_array.reshape(2,3,4)
return zeros_array_reshaped


array_reshaped_zeros()

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
# Enter solution here
def create_3d_array():
N=28
arr = np.arange(0,(N-1))
arr2 = arr.reshape((3,3,3))
print(arr2)
return arr2

create_3d_array()

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):
my_data = np.genfromtxt(path, delimiter=',',skip_header=1,dtype=dtype)
return my_data

read_csv_data_to_ndarray(path,np.float64)


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

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


return ipl_matches_array

read_ipl_data_csv(path,'|S50')

# Enter code here
12 changes: 11 additions & 1 deletion q06_get_unique_matches_count/build.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# %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 pandas as pd
# Enter Code Here
def get_unique_matches_count():
df=pd.read_csv(path,delimiter=',')
counts=df['match_code'].nunique()
return counts


get_unique_matches_count()


29 changes: 27 additions & 2 deletions q07_get_unique_teams_set/build.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,30 @@
# %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
# Enter Code Here
def read_ipl_data_csv():
data=np.genfromtxt(path,delimiter=',',dtype=None)
return data

def get_unique_teams_set():
data= read_ipl_data_csv()
team11=data[1:,3]
team1=np.unique(team11)
team22=data[1:,4]
team2=np.unique(team22)

good=np.union1d(team1,team2)
list1=good.tolist()
set1=set(list1)
return set1


get_unique_teams_set()






15 changes: 13 additions & 2 deletions q08_get_total_extras/build.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
# %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():
count=0
data=np.genfromtxt(path,delimiter=',')
extras=data[1:,17]
runs=np.sum(extras,dtype=int)
return runs


get_total_extras()