[New-bugs-announce] [issue30116] numpy.ndarray.T doesn't change the structure
m.meliani
report at bugs.python.org
Thu Apr 20 08:08:52 EDT 2017
New submission from m.meliani:
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.
----------
messages: 291967
nosy: m.meliani
priority: normal
severity: normal
status: open
title: numpy.ndarray.T doesn't change the structure
type: behavior
versions: Python 2.7
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue30116>
_______________________________________
More information about the New-bugs-announce
mailing list