NumPy data access and analysis functions of the python 3

Statistical functions in NumPy

sum(a,axis = None): According to a given axis axis calculation array a correlation sum of elements, axis integers or tuple of
mean(a,axis = None): calculating a given shaft axis array desired a relevant element, axis integers or tuple of
average(a,axis = None,weights = None): calculating a given shaft axis array a related element weighted average
std(a,axis = None): shaft axis is calculated according to a given array element related to a difference in the standard
var(a,axis = None): calculate the variance of a given shaft axis array according to a related element

np.min(a,axis = None)或a.min(axis = None),np.max(a,axis = None)或a.max(axis = None): The minimum value of the array of elements in a maximum

import numpy as np
a = np.array([[1,5,3],[4,2,6]])
print(a.min()) #无参,所有中的最小值
print(a.min(0)) # axis=0; 每列的最小值
print(a.min(1)) # axis=1;每行的最小值

np.argmin(a,axis = None)或a.argmin(axis = None),np.argmax(a,axis = None)或a.argmax(axis = None): The minimum value of the array of elements in a maximum after a drop of index-dimensional
unravel_index(index,shape): The one-dimensional shape is converted into a multi-dimensional index index index

a = np.arange(15).reshape(3,5)
np.random.shuffle(a)
print(a)
np.argmin(a)
index = np.unravel_index(np.argmin(a),a.shape)
print(index)

ptp(a): Calculating an array of elements in a difference between maximum and minimum values
median(a): calculating a median of the array elements

Published 28 original articles · won praise 8 · views 2870

Guess you like

Origin blog.csdn.net/atuo200/article/details/98908103