Как извлечь массив из нескольких массивов? - PullRequest
0 голосов
/ 01 февраля 2020

У меня есть такой массив (два массива в одном массиве)

(array([[-4.07401555, -1.12762701],
    [-3.88560227, -0.06118285],
    [-4.62934541, -0.88130313],
    [-3.09753324, -2.02348053],
    [-4.02772738, -0.64143472],
    [-3.29449629,  3.53823483],
    [-4.90149478, -4.61461214],
    [-4.20785583, -2.07414533],
    [-3.80984591, -1.54991827],
    [-3.94756787, -1.94410177],
    [-4.12733094,  0.99739835],
    [-4.78934387,  5.93458153],
    [-4.22179258, -1.79831781],
    [-4.22780001, -0.95118445],
    [-5.63862134, -0.3368916 ],
    [-2.69788317, -0.3584307 ],
    [-5.550479  ,  1.26985438],
    [-3.85037798,  2.71857616],
    [-1.17284044, -5.37676505],
    [-0.372862  , -2.21266946],
    [-1.59758915, -2.35094283],
    [ 1.0377096 , -2.63327782],
    [-2.28374243, -0.86185388],
    [-2.18484182,  0.1311334 ],
    [-2.58431247, -4.10951364],
    [-0.01539063, -1.63587608],
    [-1.85354578, -1.30641768],
    [-0.98808245, -0.61461008],
    [-1.92604127, -0.58107918],
    [ 1.8642101 ,  4.79139957],
    [-2.93468355, -3.45856658],
    [-1.4451163 , -0.20335426],
    [-4.65527271, -1.6458597 ],
    [-2.49320437, -2.86293507],
    [-3.78240948,  0.68087179],
    [-1.89456471,  4.57759581],
    [ 8.24100545, -5.45407738],
    [ 9.91779051, -0.99071911],
    [ 9.84875078, -1.50870909],
    [ 9.27925524, -0.81510372],
    [ 9.26234989, -3.62163468],
    [10.82960616,  0.74151533],
    [-3.47313729, -3.43425963],
    [-1.02527078, -2.47598464],
    [-4.45170984, -0.18781308],
    [-4.18821533,  0.2945452 ],
    [-5.67449887,  0.97290786],
    [-2.592174  ,  2.21374577],
    [ 5.55348111, -4.81467309],
    [ 7.20918881, -2.73222005],
    [ 6.32418201, -2.26742884],
    [ 7.85312512, -1.78531997],
    [ 6.09384986, -0.73985944],
    [ 8.8108482 , -0.57372231],
    [-1.04806282,  1.33924165],
    [-1.86383069,  4.6344584 ],
    [-2.11317864,  4.00291139],
    [ 0.17477389,  4.13393326],
    [-0.17422961,  6.91572322],
    [ 1.96450072,  9.94484856],
    [ 3.21998132,  0.71938671],
    [ 3.14761124,  1.76238475],
    [ 3.90526952,  2.47792389],
    [ 4.85504442,  2.23695697],
    [ 6.53057756,  4.91429747],
    [ 7.8448093 ,  7.6734504 ]]),
 array([-0.65918338, -0.69360276, -0.62476399, -0.65918338, -0.59034461,
    -0.48708645, -0.72802215, -0.79686092, -0.76244153, -0.79686092,
    -0.72802215, -0.69360276, -0.65918338, -0.59034461, -0.62476399,
    -0.65918338, -0.48708645, -0.48708645, -0.76244153, -0.69360276,
    -0.62476399, -0.72802215, -0.65918338, -0.52150584, -0.65918338,
    -0.69360276, -0.59034461, -0.48708645, -0.69360276,  0.51107572,
    -0.65918338, -0.72802215, -0.65918338, -0.65918338, -0.69360276,
    -0.45266707,  0.57991449,  1.88785113,  1.92227052,  1.9566899 ,
     0.85526957,  2.47298068, -0.55592522, -0.79686092, -0.65918338,
    -0.65918338, -0.72802215, -0.52150584, -0.1428926 , -0.03963444,
     0.75201142,  0.51107572, -0.10847321,  1.54365728,  0.16688187,
    -0.03963444,  0.47665634,  0.92410834,  0.30455941,  0.68317265,
     1.50923789,  1.19946343,  2.12878683,  1.23388281,  2.67949699,
     2.64507761]))

Я хочу извлечь только этот массив:

array([[-4.07401555, -1.12762701],
    [-3.88560227, -0.06118285],
    [-4.62934541, -0.88130313],
    [-3.09753324, -2.02348053],
    [-4.02772738, -0.64143472],
    [-3.29449629,  3.53823483],
    [-4.90149478, -4.61461214],
    [-4.20785583, -2.07414533],
    [-3.80984591, -1.54991827],
    [-3.94756787, -1.94410177],
    [-4.12733094,  0.99739835],
    [-4.78934387,  5.93458153],
    [-4.22179258, -1.79831781],
    [-4.22780001, -0.95118445],
    [-5.63862134, -0.3368916 ],
    [-2.69788317, -0.3584307 ],
    [-5.550479  ,  1.26985438],
    [-3.85037798,  2.71857616],
    [-1.17284044, -5.37676505],
    [-0.372862  , -2.21266946],
    [-1.59758915, -2.35094283],
    [ 1.0377096 , -2.63327782],
    [-2.28374243, -0.86185388],
    [-2.18484182,  0.1311334 ],
    [-2.58431247, -4.10951364],
    [-0.01539063, -1.63587608],
    [-1.85354578, -1.30641768],
    [-0.98808245, -0.61461008],
    [-1.92604127, -0.58107918],
    [ 1.8642101 ,  4.79139957],
    [-2.93468355, -3.45856658],
    [-1.4451163 , -0.20335426],
    [-4.65527271, -1.6458597 ],
    [-2.49320437, -2.86293507],
    [-3.78240948,  0.68087179],
    [-1.89456471,  4.57759581],
    [ 8.24100545, -5.45407738],
    [ 9.91779051, -0.99071911],
    [ 9.84875078, -1.50870909],
    [ 9.27925524, -0.81510372],
    [ 9.26234989, -3.62163468],
    [10.82960616,  0.74151533],
    [-3.47313729, -3.43425963],
    [-1.02527078, -2.47598464],
    [-4.45170984, -0.18781308],
    [-4.18821533,  0.2945452 ],
    [-5.67449887,  0.97290786],
    [-2.592174  ,  2.21374577],
    [ 5.55348111, -4.81467309],
    [ 7.20918881, -2.73222005],
    [ 6.32418201, -2.26742884],
    [ 7.85312512, -1.78531997],
    [ 6.09384986, -0.73985944],
    [ 8.8108482 , -0.57372231],
    [-1.04806282,  1.33924165],
    [-1.86383069,  4.6344584 ],
    [-2.11317864,  4.00291139],
    [ 0.17477389,  4.13393326],
    [-0.17422961,  6.91572322],
    [ 1.96450072,  9.94484856],
    [ 3.21998132,  0.71938671],
    [ 3.14761124,  1.76238475],
    [ 3.90526952,  2.47792389],
    [ 4.85504442,  2.23695697],
    [ 6.53057756,  4.91429747],
    [ 7.8448093 ,  7.6734504 ]]),

Я пытался np.ndarray.flatten и np.vstack(tuple(arr)). Ни один из них не работает. Мне дают ошибку descriptor 'flatten' requires a 'numpy.ndarray' object but received a 'tuple' и all the input array dimensions except for the concatenation axis must match exactly соответственно

1 Ответ

0 голосов
/ 01 февраля 2020

Самый простой способ - использовать индексирование.

Например, в вашем случае a[0] (получение первого элемента массива) должно работать нормально, независимо от формы ваших массивов.

...