Home > Mobile >  How to convert nested array list to array
How to convert nested array list to array

Time:04-01

array([[ 6402,742,6402],[2748,1994,287],[406,1214,68]])

I want to convert to..

array([6402,742,6402],[2748,1994,287],[406,1214,68])

CodePudding user response:

The first is a valid 2d array:

In [301]: x=np.array([[ 6402,742,6402],[2748,1994,287],[406,1214,68]])
In [302]: x.shape
Out[302]: (3, 3)

In [304]: x
Out[304]: 
array([[6402,  742, 6402],
       [2748, 1994,  287],
       [ 406, 1214,   68]])

The second isn't a valid array display.

Without an array wrapper, it's a tuple of lists:

In [305]: [6402,742,6402],[2748,1994,287],[406,1214,68]
Out[305]: ([6402, 742, 6402], [2748, 1994, 287], [406, 1214, 68])
  • Related