Numpy 的 transpose(~)
方法翻轉行和列,就像在矩陣中一樣。
參數
1. a
| array-like
輸入數組。
2. axes
| int
的list
| optional
執行轉置所沿的軸。默認情況下,翻轉 2D 數組的列和行。
返回值
如果 a
是標量,則返回標量。否則,返回一個 Numpy 數組。
例子
考慮以下二維數組:
a = np.array([[4,5],[6,7]])
a
array([[4, 5],
[6, 7]])
進行轉置給出:
np.transpose(a)
array([[4, 6],
[5, 7]])
注意行和列是如何翻轉的。
相關用法
- Python tracemalloc.Traceback.format用法及代碼示例
- Python NumPy tri方法用法及代碼示例
- Python trunc()用法及代碼示例
- Python NumPy trim_zeros方法用法及代碼示例
- Python NumPy true_divide方法用法及代碼示例
- Python NumPy trunc方法用法及代碼示例
- Python torch.distributed.rpc.rpc_async用法及代碼示例
- Python torch.nn.InstanceNorm3d用法及代碼示例
- Python tf.compat.v1.distributions.Multinomial.stddev用法及代碼示例
- Python tf.compat.v1.distribute.MirroredStrategy.experimental_distribute_dataset用法及代碼示例
- Python torchaudio.transforms.Fade用法及代碼示例
- Python tf.compat.v1.data.TFRecordDataset.interleave用法及代碼示例
- Python tf.summary.scalar用法及代碼示例
- Python tf.linalg.LinearOperatorFullMatrix.matvec用法及代碼示例
- Python tf.linalg.LinearOperatorToeplitz.solve用法及代碼示例
- Python tf.raw_ops.TPUReplicatedInput用法及代碼示例
- Python tf.raw_ops.Bitcast用法及代碼示例
- Python tf.compat.v1.distributions.Bernoulli.cross_entropy用法及代碼示例
- Python Pandas tseries.offsets.CustomBusinessHour.onOffset用法及代碼示例
- Python torch.special.gammaincc用法及代碼示例
- Python typing.get_type_hints用法及代碼示例
- Python tensorflow.math.xlog1py()用法及代碼示例
- Python tf.compat.v1.Variable.eval用法及代碼示例
- Python tf.compat.v1.train.FtrlOptimizer.compute_gradients用法及代碼示例
- Python tf.distribute.OneDeviceStrategy.experimental_distribute_values_from_function用法及代碼示例
注:本文由純淨天空篩選整理自Isshin Inada大神的英文原創作品 NumPy | transpose method。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。