python 语言中 np.array ([[1,2]]).T 是进行什么运算?尝试了一下,跑不通
我在某课程看到一个用法c = np.array([[1,2]]).T 我想看看.T起什么作用。于是想跑跑这段代码,但是报错。还请高手指教,谢谢!
import numpy as np
b = np.array([1,2,3,0,6],[15,8,9,10,9])
c = np.array([[1,2]]).T
print (b)
print (c)
报错信息如下:
TypeError Traceback (most recent call last)
in
2 #!--coding:UTF-8 --
3 import numpy as np
—-> 4 b = np.array([1,2,3,0,6],[15,8,9,10,9])
5 c = np.array([[1,2]]).T
6 print (b)
TypeError: data type not understood
与T无关,T只是返回ndarray类型,与np.array() 参数相关, 换而言之,你第二行代码入参数据类型不对。numpy.array第一个位置参数必须是有序序列,其方法原型如下
输出