Why wont numpy matrix let me print its rows?
- by uberjumper
Okay this is probably a really dumb question, however its really starting to hurt. I have a numpy matrix, and basically i print it out row by row. However i want to make each row be formatted and separated properly.
>>> arr = numpy.matrix([[x for x in range(5)] for y in range(5)])
>>> arr
matrix([[0, 1, 2, 3, 4],
[0, 1, 2, 3, 4],
[0, 1, 2, 3, 4],
[0, 1, 2, 3, 4],
[0, 1, 2, 3, 4]])
Lets say i want to print the first row, and add a '|' between each element:
>>> '|'.join(map(str, arr[0,]))
'[[0 1 2 3 4]]'
Err...
>>> '|'.join(map(lambda x: str(x[0]), arr[0]))
'[[0 1 2 3 4]]'
I am really confused by this behavior why does it do this?