classification
Title: numpy.ndarray.T doesn't change the structure
Type: behavior Stage: resolved
Components: Versions: Python 2.7
process
Status: closed Resolution: third party
Dependencies: Superseder:
Assigned To: Nosy List: m.meliani, r.david.murray
Priority: normal Keywords:

Created on 2017-04-20 12:08 by m.meliani, last changed 2017-04-20 14:27 by r.david.murray. This issue is now closed.

Messages (2)
msg291967 - (view) Author: (m.meliani) Date: 2017-04-20 12:08
The few following lines, i believe, show how the numpy.ndarray.T or numpy.ndarray.transpose() don't change the structure of the data only the way they're displayed. Which is sometimes a problem when handling big quantities of data which you need to look at a certain way for sorting problems among others.

>>> import numpy as np
>>> x=np.array([[0,1,2],[1,2,3]])
>>> x=x.T
>>> print x
[[0 1]
 [1 2]
 [2 3]]
>>> y=np.array([[0,1],[1,2],[2,3]])
>>> print y
[[0 1]
 [1 2]
 [2 3]]
>>> y.view('i8,i8')
array([[(0, 1)],
       [(1, 2)],
       [(2, 3)]],
      dtype=[('f0', '<i8'), ('f1', '<i8')])
>>> x.view('i8,i8')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: new type not compatible with array.
msg291975 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2017-04-20 14:27
Numpy is not part of the Python standard library.  You'll need to engage with the numpy community on this question.  (I say engage with them on the question, not report a bug to them, because I highly doubt this is a bug...there's probably some way to do what you want, so I suggest asking a question first rather than reporting a bug).
History
Date User Action Args
2017-04-20 14:27:46r.david.murraysetstatus: open -> closed

nosy: + r.david.murray
messages: + msg291975

resolution: third party
stage: resolved
2017-04-20 12:08:52m.melianicreate