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

 

·reshape()

In many cases, you can convert an array from one shape to another without copying any data. To do this, pass a tuple indicating the new shape to the reshape array instance method.

NumPy advanced array manipulation

NumPy advanced array manipulation

 

A multidimensional array can also be reshaped:

NumPy advanced array manipulation

 

One of the passed shape dimensions can be -1, in which case the value used for that dimension will be inferred from the data:

NumPy advanced array manipulation

 

The opposite operation of reshape from one-dimensional to a higher dimension is typically known as flattening or raveling

·ravel()

The ravel method does not produce a copy of the underlying values if the values in the result were contiguous in the original array

NumPy advanced array manipulation

 

·flatten()

The flatten method behaves like ravel except it always returns a copy of the data

NumPy advanced array manipulation


·transpose()

For higher dimensional arrays, transpose will accept a tuple of axis numbers to permute the axes:

NumPy advanced array manipulation

 

np.concatenate

numpy.concatenate takes a sequence (tuple, list, etc.) of arrays and joins them together in order along the input axis

NumPy advanced array manipulation

 

np.split

split slices apart an array into multiple arrays along an axis

NumPy advanced array manipulation

 

2 equal division where axis = 1

NumPy advanced array manipulation

 

Reference

Python for Data Analysis Second Edition

相关文章: