Nov-20-2019, 07:07 PM
I'm attempting to create my first 2 dimensional array. But I'm not getting the anticipated results:
array([list([11, 12, 13]), list([21.22, 23]), list([31, 32, 33])],
dtype=object)
I'm expecting x.ndim to return 2 since it's a List containing 3 other Lists, but it's only returning 1.
I'm expecting x.shape to return (3,3,), but instead it's returning (3,)
Any help would be greatly appreciated.
import numpy as np a = [[11,12,13],[21.22,23],[31,32,33]] # nested list x = np.array(a) # cast into an array xMy Results:
array([list([11, 12, 13]), list([21.22, 23]), list([31, 32, 33])],
dtype=object)
I'm expecting x.ndim to return 2 since it's a List containing 3 other Lists, but it's only returning 1.
I'm expecting x.shape to return (3,3,), but instead it's returning (3,)
Any help would be greatly appreciated.