2

This is the result I get:

a=[array([[ 0.05019716]]), array([[ 0.04085874]])]

I would like to create such a list:

list_numbers=[ 0.05019716, 0.04085874]

Any advice will be appreciated

1 Answer 1

2

Here's one way

In [9]: np.array(a).ravel().tolist()
Out[9]: [0.05019716, 0.04085874]

Convert a, list, to NumPy array, then flatten it to array elements using ravel(), then convert to list using tolist().

However, for this specific case, you could also use list comprehensions

In [10]: [x[0][0] for x in a]   # or x[0, 0]
Out[10]: [0.050197159999999998, 0.040858739999999998]
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.