Back
I would like to create the 2D array with respect to elements, something like:
np.array([[1, 0], [1, 0], [1, 0]])
And wanted the shape to be (1000, 2).
Try the below code:
import numpy as nparr=np.tile(np.array([0,1]),(1000,1))
import numpy as np
arr=np.tile(np.array([0,1]),(1000,1))
which gives out put as fallows:
>>> print(arr)[[0 1] [0 1] [0 1] ... [0 1] [0 1] [0 1]]
>>> print(arr)
[[0 1]
[0 1]
...
[0 1]]
And has a shape:
>>> arr.shape(1000, 2)
>>> arr.shape
(1000, 2)
Learn data science with python course to improve your technical knowledge.
31k questions
32.8k answers
501 comments
693 users