0

I have a numpy array like this:

a = [[0.04393, 0.0, 0.0], [0.04393, 0.005, 0.0], [0.04393, 0.01, 0.0],[0.04393, 0.015, 0.0]]

And i want to format it in this:

b = [((0.04393, 0.0, 0.0), ), ((0.04393, 0.005, 0.0), ), ((0.04393, 
0.01, 0.0), ), ((0.04393, 0.015, 0.0), )]

How can i do it?

3
  • 1
    Where did the 0.14625 come from? Commented Apr 11, 2016 at 22:16
  • Sorry, it should be the same numbers, now it is correct. Commented Apr 11, 2016 at 22:21
  • Arrays don't look like lists of lists, but in any case, it seems you want to convert an array with shape (M, N) to (M, 1, N). docs.scipy.org/doc/numpy-1.10.1/reference/generated/… Commented Apr 11, 2016 at 22:35

1 Answer 1

3

This will do:

a = [[0.04393, 0.0, 0.0], [0.04393, 0.005, 0.0], [0.04393, 0.01, 0.0],[0.04393, 0.015, 0.0]]
b = [ (tuple(a1),) for a1 in a]
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.