how to convert two dimension array to one dimension in python?

Viewed 1871

I have an array looks like this (two dimensions):

[[1.]
 [1.]
 [1.]
 [1.]
 [1.]
 [1.]
 [1.]
 [0.]
 [0.]
 [1.]
 [1.]
 [1.]
 [1.]
 [1.]
 [1.]
 [1.]
 [1.]
 [1.]
 [0.]
 [1.]
 [1.]
 [1.]
 [1.]
 [0.]
 [1.]]

How can I change it to: [1 1 1 1 ............1 0 1] I've been looking for solution for a whole afternoon but still got no idea, can someone give me some hint, thanks.

1 Answers

On a numpy array a:

np.squeeze(a)

or

a.flatten()
Related