Tell us what’s happening:
I’m trying to understand and practice numpy.
While doing a particular project,
even though the output matches what’s required,
it keeps throwing errors.
Could someone please guide me?
Your code so far
import numpy as np
def calculate(list):
if len(list)!=9:
print("List should have 9 elements")
ls=list.reshape((3,3))
calculations={
'mean':[(np.mean(ls,axis=1)).tolist(), (np.mean(ls,axis=0)).tolist(), np.mean(ls)],
'variance':[(np.var(ls,axis=1)).tolist(), (np.var(ls,axis=0)).tolist(), np.var(ls)],
'standard deviation':[(np.std(ls,axis=1)).tolist(), (np.std(ls,axis=0)).tolist(), np.std(ls)],
'max':[(np.max(ls,axis=1)).tolist(), (np.max(ls,axis=0)).tolist(), np.max(ls)],
'min':[(np.min(ls,axis=1)).tolist(), (np.min(ls,axis=0)).tolist(), np.min(ls)],
'sum':[(np.sum(ls,axis=1)).tolist(), (np.sum(ls,axis=0)).tolist(), np.sum(ls)]}
return(calculations)
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.75 Safari/537.36
.
Challenge: Mean-Variance-Standard Deviation Calculator
Link to the challenge: