Reputation: 29
Let's assume I have an 2D array named 'example'
example = np.array([[14],[34],[234],[17],[80],[4563],[1456],[2345],[3456],[34565]])
What I want to do here is to transform the array to a list that looks like:
[14, 34, 234, 17, 80, 4563, 1456, 2345, 3456, 34565]
How can I get the above list from the array?
Upvotes: 0
Views: 66
Reputation: 249123
I would do it this way, as it seems to be the most natural expression of what you're trying to do:
example.flatten().tolist()
Upvotes: 2