The document numpy.ndarray.T says
ndarray.T — Same as self.transpose(), except that self is returned if self.ndim < 2.
Also, ndarray.transpose(*axes) says
For a 1-D array, this has no effect.
Doesn't this mean the same thing?
Here's a little demo snippet:
>>> import numpy as np >>> print np.__version__ 1.5.1rc1 >>> a = np.arange(7) >>> print a, a.T, a.transpose() [0 1 2 3 4 5 6] [0 1 2 3 4 5 6] [0 1 2 3 4 5 6]
T is just a convenient notation, and that . transpose(*axes) is the more general function and is intended to give more flexibility, as axes can be specified.
ndarray. ndim() function return the number of dimensions of an array.
numpy. array is just a convenience function to create an ndarray ; it is not a class itself. You can also create an array using numpy. ndarray , but it is not the recommended way.
The . T accesses the attribute T of the object, which happens to be a NumPy array. The T attribute is the transpose of the array, see the documentation. Apparently you are creating random coordinates in the plane.
Regardless of rank, the .T
attribute and the .transpose()
method are the same—they both return the transpose of the array.
In the case of a rank 1 array, the .T
and .transpose()
don't do anything—they both return the array.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With