0

I want to change a 2d array a = [[1,2,3] [3,4,5] [6,7,8] [9,10,11]] into

b= [[9,10,11]
[6,7,8]
[3,4,5]
[1,2,3]]

using numpy package

3
  • 1
    .. numpy.flipud? Commented Jul 23, 2019 at 15:23
  • 1
    or a[::-1, :]? Commented Jul 23, 2019 at 15:25
  • Also, those are python lists, not numpy arrays... Commented Jul 23, 2019 at 15:25

1 Answer 1

1

This looks like task for numpy.flip, that is:

import numpy as np
a = np.array([[1,2,3],[3,4,5],[6,7,8],[9,10,11]])
b = np.flip(a,0)
print(b)

Output:

[[ 9 10 11]
 [ 6  7  8]
 [ 3  4  5]
 [ 1  2  3]]
Sign up to request clarification or add additional context in comments.

Comments

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.