Numpy Array Shape Tutorials

Publié le: 16 mars 2023
sur la chaîne: Programming Academic
20
1

In NumPy, the shape of a numpy array is a tuple of integers that describes the number of elements in each dimension of the array. It can be obtained using the shape attribute of the numpy array. For example:

import numpy as np

arr = np.array([[1, 2, 3], [4, 5, 6]])
print(arr.shape)
Output:


(2, 3)
Here, arr is a 2-dimensional array with 2 rows and 3 columns, so its shape is (2, 3).

Similarly, for a 1-dimensional array, the shape will be a single integer indicating the number of elements in the array. For example:


arr = np.array([1, 2, 3])
print(arr.shape)
Output:


(3,)
Here, arr is a 1-dimensional array with 3 elements, so its shape is (3,)


Sur cette page du site, vous pouvez voir la vidéo en ligne Numpy Array Shape Tutorials durée heure minute seconde en bonne qualité , qui a été Téléchargé par l'utilisateur Programming Academic 16 mars 2023, Partagez le lien avec vos amis et connaissances, sur youtube cette vidéo a déjà été regardée 20 fois et il a aimé 1 téléspectateurs. Bon visionnage!