0

So I have some data which are in this format:

[array([[0.00849484],[0.00830291],[0.00735711]]) array([[0.00795935],[0.00772346],[0.00740238]])...] 

How can I convert it into simple 1D array?

[0.00849484 0.00830291 0.00735711 0.00795935 0.00772346 0.00740238] 
3
  • are those arrays numpy? Commented Jun 13, 2021 at 9:29
  • np.array(a).ravel().tolist(). Commented Jun 13, 2021 at 9:32
  • @aaronn yes, numpy arrays Commented Jun 13, 2021 at 9:32

1 Answer 1

0

if a is array

a = np.array([np.array([[0.00849484],[0.00830291],[0.00735711]]), np.array([[0.00795935],[0.00772346],[0.00740238]])]) 

result

array([[[0.00849484], [0.00830291], [0.00735711]], [[0.00795935], [0.00772346], [0.00740238]]]) 

use flatten

a.flatten() 

result (numpy array)

array([0.00849484, 0.00830291, 0.00735711, 0.00795935, 0.00772346, 0.00740238]) 
a.flatten().tolist() 

result (python list)

[0.00849484, 0.00830291, 0.00735711, 0.00795935, 0.00772346, 0.00740238] 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.