NumPy array statistical methods and sorting

原创转载请注明出处:https://www.cnblogs.com/agilestyle/p/12247717.html

 

Basic array statistical methods

A set of mathematical functions that compute statistics about an entire array or about the data along an axis are accessible as methods of the array class.

You can use aggregations(often called reductions) like sum, mean, and std (standard deviation) either by calling the array instance method or using the top-level NumPy function.

 

Functions like mean, sum, max and min take an optional axis argument that computes the statistic over the given axis, resulting in an array with one fewer dimension

 

Other methods like cumsum and cumprod do not aggregate, instead producing an array of the intermediate results. In multidimensional arrays, accumulation functions like cumsum return an array of the same size, but with the partial aggregates computed along the indicated axis according to each lower dimensional slice.

 

Sorting

Like Python’s built-in list type, NumPy arrays can be sorted in-place with the sort method. You can also sort each one-dimensional section of values in a multidimensional array inplace along an axis by passing the axis number to sort.

 

Reference

Python for Data Analysis Second Edition

posted @ 2020-02-01 10:36  李白与酒  阅读(179)  评论(0编辑  收藏  举报