Answers for "NumPy Array Shape"

2

numpy shape get

>>> np.shape(np.eye(3))
(3, 3)
>>> np.shape([[1, 2]])
(1, 2)
>>> np.shape([0])
(1,)
>>> np.shape(0)
()
Posted by: Guest on June-08-2021
0

NumPy Array Shape

import numpy as np

arr = np.array([1, 2, 3, 4], ndmin=5)

print(arr)
print('shape of array :', arr.shape)
Posted by: Guest on February-01-2021
0

numpy randn with a shape of another array

a = np.zeros([2, 3])
print(a.shape)
# outputs: (2, 3)
b = np.random.randn(*a.shape)
print(b.shape)
# outputs: (2, 3)
Posted by: Guest on December-17-2020
0

numpy shape

>>> a = np.array([(1, 2), (3, 4)], dtype=[('x', 'i4'), ('y', 'i4')])
>>> np.shape(a)
(2,)
>>> a.shape
(2,)
Posted by: Guest on September-12-2020

Python Answers by Framework

Browse Popular Code Answers by Language