1. Array conversion
ndarray.tolist() --- Return the array as a (possibly nested) list.
ndarray.astype(dtype[, order, casting, ...]) --- Copy of the array, cast to a specified type.ndarray.copy([order]) --- Return a copy of the array.
ndarray.fill(value) --- Fill the array with a scalar value.
2. Shape manipulation
ndarray.reshape(shape[, order]) --- Returns an array containing the same data with a new shape.
ndarray.resize(new_shape[, refcheck]) --- Change shape and size of array in-place.
ndarray.flatten([order]) --- Return a copy of the array collapsed into one dimension.
ndarray.ravel([order]) --- Return a flattened array.
Difference between reshape and resize is: reshape does not affect the raw array; resize directly change the raw array
Difference between flatten and ravel is: the ravel array's entries are affected by the raw array's value change; the flatten array is a totally different new array.
3. Item selection
ndarray.sort([axis, kind, order]) --- Sort an array, in-place.
ndarray.argsort([axis, kind, order]) --- Returns the indices that would sort this array.
ndarray.repeat(repeats[, axis]) --- Repeat elements of an array.
4. Calculation
The calculation functions are quite straightforward: ndarray.func([axis, out]), however, remember that there are one major parameters: axis.
If axis is None (the default), the array is treated as a 1-D array and the operation is performed over the entire array.
If axis is an integer, then the operation is done over the given axis (for each 1-D subarray that can be created along the given axis).
No comments:
Post a Comment