10 examples of 'how to find mean in python' in Python

Every line of 'how to find mean in python' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
52def mean(X):
53 return sum(X) / len(X)
36def mean(x): return sum(x)/len(x)
5def mean(x):
6 from numpy import sum
7 return sum(x)/len(x)
557def safe_mean(arr):
558 """
559 Compute the mean of an array if there is at least one element.
560 For empty array, return nan. It is used for logging only.
562 :param arr: (np.ndarray)
563 :return: (float)
564 """
565 return np.nan if len(arr) == 0 else np.mean(arr)
159def mean_list(x, y):
160 res = []
161 for i, j in zip(x, y):
162 res.append(round(mean(i, j), 3))
163 return res
10def mean(array):
11 if len(array)==0:
12 return 0.
13 else:
14 return numpy.mean(array)
358def getMean(self, values):
359 return float(sum(values))/len(values)
26def mean(l):
27 return sum(l)/len(l)
35def mean(l):
36 """Returns the arithmetic mean of list l, as a float"""
37 return sum(l) / len(l)
57def mean(l):
58 return 1.0 * sum(l) / len(l)

Related snippets