0

I'm needing to combine the rows in this array:

array([[0.        , 1.        , 0.44768612],
       [0.34177215, 1.        , 0.        ]])

So that the output is:

array([[0., 0.34177215], [1., 1.], [0.44768612, 0.])

But for some reason, I can't figure it out with the reshape function. Any help would be appreciated.

3
  • Do you want the output as a list or an array? Commented Nov 2, 2019 at 21:35
  • @James An array, I forgot to add it as I wrote the desired output myself Commented Nov 2, 2019 at 21:36
  • @wwii I have a ten-minute cooldown until I can accept an answer... Commented Nov 2, 2019 at 21:48

2 Answers 2

2

If x is your array, x.T will transpose it:

array([[0.        , 1.        , 0.44768612],
       [0.34177215, 1.        , 0.        ]])

becomes

array([[0.        , 0.34177215],
       [1.        , 1.        ],
       [0.44768612, 0.        ]])
Sign up to request clarification or add additional context in comments.

Comments

2

if array is A, just do A.T...

1 Comment

It's not T(), just T

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.