AttributeError: 'builtin_function_or_method' object has no attribute 'tolist'

import numpy as np

import numpy as np
calculations = {}
def calculate(list):
array_1 = np.array(list)
except len(list)<9:
print(“List must contain nine numbers”)
new_array = array_1.reshape(3,3)
calculations[‘mean’] = [(new_array.mean(axis = 0).tolist()),(new_array.mean(axis = 1).tolist()),(new_array.mean.tolist())]

calculations[‘variance’] = [(new_array.var(axis = 0).tolist()), (new_array.var(axis = 1).tolist()), (new_array.var().tolist())]

calculations[‘standard deviation’] = [(new_array.std(axis = 0).tolist()), (new_array.std(axis = 1).tolist()),(new_array.std().tolist())]

calculations[‘max’] = [(new_array.max(axis = 0).tolist()), (new_array.max(axis = 1).tolist()), (new_array.max().tolist())]

calculations[‘min’] = [(new_array.min(axis = 0).tolist()), (new_array.min(axis = 1).tolist()),(new_array.min().tolist())]

calculations[‘sum’] = [(new_array.sum(axis = 0).tolist()), (new_array.sum(axis = 1).tolist()), (new_array.sum().tolist())]

return calculations

The error message should point you towards a line in the code, where the problem is occuring.
After a quick glance, it looks like you forgot the “()” on a method you called.

thanks for the correction. I have spotted it

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