Data Analysis with Python Projects - Mean-Variance-Standard Deviation Calculator

Tell us what’s happening:
I am getting an error when running main.py as follows:
ModuleNotFoundError: No module named ‘numpy’ from the mean_var_std.py program

Your code so far
Here is my mean_var_std.py code:
import numpy as np

def calculate(list):

Check to see if the input list contains exactly 9 digits

if len(lst) != 9:
raise ValueError(“Input list must contain 9 digits”)

Convert the input list into a 3x3 numpy array

matrix = np.array(list).reshape(3, 3)

Calculate statistics to return the mean, variance, standard deviation, max, min, and sum of the rows, columns, and elements of the array

stats = {
‘mean’ : [np.mean(matrix, axis=0).tolist(), np.mean(matrix, axis=1).tolist(), np.mean(matrix).tolist()],
‘variance’ : [np.var(matrix,axis=0).tolist(), np.var(matrix, axis=1).tolist(), np.var(matrix).tolist()],
‘std_dev’ : [np.std(matrix,axis=0).tolist(), np.std(matrix, axis=1).tolist(), np.std(matrix).tolist()],
‘max’ : [np.max(matrix,axis=0).tolist(), np.max(matrix, axis=1).tolist(), np.max(matrix).tolist()],
‘min’ : [np.min(matrix,axis=0).tolist(), np.min(matrix, axis=1).tolist(), np.min(matrix).tolist()],
‘sum’ : [np.sum(matrix,axis=0).tolist(), np.sum(matrix, axis=1).tolist(), np.sum(matrix).tolist()]
}

return stats

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.5.2 Safari/605.1.15

Challenge: Data Analysis with Python Projects - Mean-Variance-Standard Deviation Calculator

Link to the challenge:

at the Shell command prompt type pip install numpy and maybe pip install pandas

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.