“transpose numpy” Kode Jawaban

transpose numpy

ndarray.T

x = np.array([[1.,2.],[3.,4.]])
>>> x
array([[ 1.,  2.],
       [ 3.,  4.]])
>>> x.T
array([[ 1.,  3.],
       [ 2.,  4.]])
>>> x = np.array([1.,2.,3.,4.])
>>> x
array([ 1.,  2.,  3.,  4.])
>>> x.T
array([ 1.,  2.,  3.,  4.])
Active Programmer

Transpose matriks dalam python tanpa numpy

def transpose(matrix):
    rows = len(matrix)
    columns = len(matrix[0])

    matrix_T = []
    for j in range(columns):
        row = []
        for i in range(rows):
           row.append(matrix[i][j])
        matrix_T.append(row)

    return matrix_T
  
Heron

transpose matriks dalam python numpy

np.transpose(x)
array([[0, 2],
       [1, 3]])
Energetic Eagle

Transpose matrice numpy

>>> import numpy as np
>>> M = np.array([[1,2,3],[4,5,6],[7,8,9]])
>>> M
array([[1, 2, 3],
       [4, 5, 6],
       [7, 8, 9]])
>>> M.T
array([[1, 4, 7],
       [2, 5, 8],
       [3, 6, 9]])
Distinct Dingo

Python Numpy Transpose Function Sintaks

numpy.transpose(a, axes=None)
Outrageous Ostrich

Jawaban yang mirip dengan “transpose numpy”

Pertanyaan yang mirip dengan “transpose numpy”

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya