Merge array to stay 2 columns

Asked

Viewed 80 times

-1

I am with 2 separate array of 1 x 1000 and would like to stay with a single of 2 x 1000.

r = array([0.56155503, 0.98218785, 0.95613911, 0.98307298, 0.55173653,
       1.04626122, 1.01631092, 1.03858722, 0.91028177, 0.5144934 ,
       0.48475944, 0.51813972, 0.47801269, 0.46473624, 1.01116655, ..., 0.47801269]
a = array([-2.88810501,  2.25605695, -2.7475582 ,  2.04899138,  2.535708  ,
       -3.06515283, -2.22965258, -0.4727647 , -0.78624631,  1.90581719,
        0.48304716, -2.05753726, -2.7154209 ,  0.4551733 , -0.25738469, ... ,-2.7154209]

I would like to stay with the array:

final = array([[0.56155503, -2.88810501],
               [0.98218785,  2.25605695],
               [0.95613911, -2.7475582],
                ...,
               [0.47801269, -2.7154209])

1 answer

2


I believe you would like a result 2 x 100, not 2 x 1000. You can do it this way:

import numpy as np

r = np.array([0.56155503, 0.98218785, 0.95613911, 0.98307298, 0.55173653,
       1.04626122, 1.01631092, 1.03858722, 0.91028177, 0.5144934 ,
       0.48475944, 0.51813972, 0.47801269, 0.46473624, 1.01116655, 0.47801269])

a = np.array([-2.88810501,  2.25605695, -2.7475582 ,  2.04899138,  2.535708  ,
       -3.06515283, -2.22965258, -0.4727647 , -0.78624631,  1.90581719,
        0.48304716, -2.05753726, -2.7154209 ,  0.4551733 , -0.25738469,-2.7154209])

final = np.append(r.reshape(-1, 1), a.reshape(-1, 1), axis=1)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.