Python simple data cleansing, data filtering method collation

Source: Internet
Author: User

There are two ways to create an array, 1. Direct assignment 2. Generation of random variables
random generation includes 4 types: Np.arange, Np.linspace (0,10,5), Np.logspace (0,2,5), Np.random.random (3,2,3)
Np.arange (10,20,2) # #左闭右开区间, start value, end value, step
Np.linspace (0,10,5) # #闭区间, starting value, terminating value, number of elements arithmetic progression
Np.logspace (0,2,5) # #闭区间, starting value (in exponential form), terminating value (in exponential form, base 10, 2 exponent), number of elements geometric series
np.random.random (3,2,3) #三维是3个, two-dimensional is 2, one-dimensional is 3

properties of the Ndarray:
The DYTPE output is the data type of the element that makes up the array, int+32
shape a tuple of each dimension size of an array, such as return (2, 5)
total number of size elements
Ndim The number of dimensions of an array, such as a three-dimensional array return is 3

Ndarry Modify the shape (only shape will change the original data, others will not):
A.reshape ( -1,5) #这里-1 means adaptive, 5 means 5 columns
A.shape (2,-1) #方法中的值同reshape, but shape changed the original array, reshape did not change the original
modifying the values in an array can be sliced
through the transpose transformation array, such as array shape from (5,8) can be converted to shape (8,5), just extract the data, the original data unchanged
convert Direct shape from (5,8) to (8,5) by property T, just extract data, original data unchanged

Subtraction between arrays, arrays and arrays , between arrays and scalars (numbers)
The matrix product of an array , with one column of values multiplied by one column of another array
Array Index of a Boolean type
Fancy Index Arr[np.ix_ ([0,3,5],[0,2,3])

general functions, one-dimensional functions, two-dimensional functions
aggregate function, Min min, max Max, mean average, etc., such as arr.min (), return a specific value
In a two-dimensional array, axis=0 represents a column, Axis=1 represents a row, such as Arr.min (axis=0), an aggregation of elements on the same column, and a row that returns the smallest value of the column.
where you can find replacements for the specified element np.where (condition, replace set value, array)
unique can exclude duplicates and return a one-dimensional array

Please forgive me, this writing is really not for people to see ... Example later look mood add

Python simple data cleansing, data filtering method collation

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.