I want to make a 2D array that in the first row has 2 elements, in the second row has 4 elements, and in the third row has 6. Below is my code:
jagged_array = np.array([
[None, None],
[None, None, None, None],
[None, None, None, None, None, None]
])
print(jagged_array)
print(jagged_array.ndim)
print(jagged_array.shape)
However, the output doesn't look right. And the dimension is 1 (I expected 2). Here is the output:
[list([None, None]) list([None, None, None, None])
list([None, None, None, None, None, None])]
1
(3,)
I want to know how I can make a 2D array with each row having different number of columns.