Skip to content

Commit Live PR #240

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

import numpy as np

def array_zeros(*zeros_array):
zeros_array = np.zeros((3,4,2))
return zeros_array





10 changes: 9 additions & 1 deletion q02_zeros_reshaped/build.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# %load q02_zeros_reshaped/build.py
# Default imports
# Default imports
import numpy as np
from greyatomlib.python_intermediate.q01_zeros_array.build import array_zeros

# Write your code

def array_reshaped_zeros():
ans = array_zeros()
return ans.reshape(2,3,4)
array_reshaped_zeros()


11 changes: 9 additions & 2 deletions q03_create_3d_array/build.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
# Default Imports

import numpy as np

# Enter solution here
def create_3d_array():
array = np.arange(27).reshape(3,3,3)
return array

create_3d_array()



16 changes: 13 additions & 3 deletions q04_read_csv_data_to_ndarray/build.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Default Imports

import csv
import numpy as np
path = "./data/ipl_matches_small.csv"
import matplotlib.pyplot as plt

def read_csv_data_to_ndarray(path, dtype):
# transform data into numpy array
data = np.genfromtxt(path,dtype, delimiter=',', skip_header=1)
return data


read_csv_data_to_ndarray('data/ipl_matches_small.csv',float)



# Enter code here
11 changes: 9 additions & 2 deletions q05_read_csv_data/build.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
# Default imports

import numpy as np

# Enter code here

def read_ipl_data_csv(path, dtype):
# transform data into numpy array
data = np.genfromtxt(path,dtype, delimiter=',', skip_header=1)
return data
read_ipl_data_csv('data/ipl_matches_small.csv', '|S50')


18 changes: 15 additions & 3 deletions q06_get_unique_matches_count/build.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# 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'

# Enter Code Here
def get_unique_matches_count ():
unique_list = []
mylist = read_ipl_data_csv('data/ipl_matches_small.csv', '|S50')
#unique_list =set(x for unique_list in mylist[0] for x in unique_list)
unique_list=set(mylist[:, 0])
print (unique_list)
ipl_matches_array = len(unique_list)
return ipl_matches_array

get_unique_matches_count()



21 changes: 18 additions & 3 deletions q07_get_unique_teams_set/build.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
# Default imports

import numpy as np
import pandas as pd
from greyatomlib.python_intermediate.q05_read_csv_data.build import read_ipl_data_csv
path = "data/ipl_matches_small.csv"

# Enter Code Here
def get_unique_teams_set():
team1 = []
team2 = []
Total_Teams = []
mylist = read_ipl_data_csv('data/ipl_matches_small.csv', '|S50')
np.set_printoptions(threshold=np.nan)
team1=list(mylist[:,3])
team2=list(mylist[:,4])
Total_Teams = set(team1+team2)
print (Total_Teams)
return Total_Teams
get_unique_teams_set()



12 changes: 11 additions & 1 deletion q08_get_total_extras/build.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
# %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():
total_extras=0
mylist = read_ipl_data_csv(path,int)
np.set_printoptions(threshold=np.nan)
total_extras=sum(list(mylist[:, 17]))
return total_extras
get_total_extras()