![]() |
Python 2 dimensional array creations - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Python 2 dimensional array creations (/thread-22635.html) |
Python 2 dimensional array creations - sharpe - Nov-20-2019 I'm attempting to create my first 2 dimensional array. But I'm not getting the anticipated results: 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. RE: Python 2 dimensional array creations - ThomasL - Nov-24-2019 There is a typo in your list a, take a careful look on every character! |