-2

My issue is this. I have an array like this :

test = array([[1],[2],[10] .... [-5]])

I want to be able to just convert this to an array that looks like this

test = [1,2,10,..., -5]

The test is a numpy array.

pawello2222
  • 46,897
  • 22
  • 145
  • 209

1 Answers1

0

You can use reshape() to change the array into 1D array as:

import numpy as np
test = np.array([[1],[2],[10],[-5]])
test=test.reshape((test.shape[0],))  # test.shape[0] gives the first dimension (the number of rows)
# reshape changes test array to one dimensional array with shape (test.shape[0],) 
print(test)
Roohollah Etemadi
  • 1,243
  • 1
  • 6
  • 18