1

Hey guys im trying to import text file into an array using numpy but it looks like when it imported them with the rows as cols and vice versa. Am I formatting the array wrong or is that what happnened?

I added a picture below:

Numpy Matrix

1 Answer 1

3

Its because you set unpack=True, unpack transposes your array.

From the numpy documentation:

unpack : bool, optional

If True, the returned array is transposed, so that arguments may be
unpacked using x, y, z = loadtxt(...). When used with a record data-type, 
arrays are returned for each field. Default is False.`

If you set it to false, it wont transpose the array.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you! I also found out that genfromtxt does the same thing.

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.