NumPy Transpose() Method: Permuting Array Axes Explained
NumPy's 'transpose()' method permutes the axes of an array by swapping the rows and columns. This means rows become columns and vice versa. For instance, a 2D array with shape (3, 4) will have a transposed shape of (4, 3). The original array's first row becomes the transposed array's first column, the second row becomes the second column, and so on.
The 'transpose()' method accepts an optional tuple of axis numbers to specify the output array's axis order. For example, a 3D array with shape (2, 3, 4) can be transposed to (4, 2, 3) by passing the tuple (2, 0, 1) to 'transpose()'. This effectively moves the original array's third axis to the first position in the transposed array, the first axis to the second, and the second axis to the third.
原文地址: https://www.cveoy.top/t/topic/lMf7 著作权归作者所有。请勿转载和采集!