“Contoh fungsi reshape python numpy” Kode Jawaban

Contoh fungsi reshape python numpy

# Welcome to softhunt.net
# Python Program illustrating
# numpy.reshape() method
 
import numpy as np
 
# array = np.arrange(8)
# The 'numpy' module has no attribute 'arrange'
array1 = np.arange(8)
print("Original array : \n", array1)
 
# shape array with 3 rows and 3 columns
array2 = np.arange(8).reshape(2, 4)
print("\narray reshaped with 2 rows and 4 columns : \n",
      array2)
 
# shape array with 4 rows and 2 columns
array3 = np.arange(8).reshape(4, 2)
print("\narray reshaped with 4 rows and 2 columns : \n",
      array3)
 
# Constructs 3D array
array4 = np.arange(8).reshape(2, 2, 2)
print("\nOriginal array reshaped to 3D : \n",
      array4)
Outrageous Ostrich

Contoh fungsi reshape python numpy

numpy.reshape(array, shape, order = 'C')
Outrageous Ostrich

Jawaban yang mirip dengan “Contoh fungsi reshape python numpy”

Pertanyaan yang mirip dengan “Contoh fungsi reshape python numpy”

Lebih banyak jawaban terkait untuk “Contoh fungsi reshape python numpy” di Python

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya