matplotlib条形图-只能将大小为1的数组转换为Python标量
我想要matplotlib条形图,但我给出了一个变量(g)的以下错误(第二个变量没有问题),我从python中的sqlite查询中获取了这些值,其形状如下:matplotlib条形图-只能将大小为1的数组转换为Python标量,python,matplotlib,Python,Matplotlib,我想要matplotlib条形图,但我给出了一个变量(g)的以下错误(第二个变量没有问题),我从python中的sqlite查询中获取了这些值,其形状如下: g= [(11,), (7,), (6,), (3,), (1,), (4,), (7,), (0,), (0,), (0,), (172,)] error TypeError: only size-1 arrays can be converted to Python scalars 当我尝试 g.values.flatten() er
g= [(11,), (7,), (6,), (3,), (1,), (4,), (7,), (0,), (0,), (0,), (172,)]
error
TypeError: only size-1 arrays can be converted to Python scalars
当我尝试
g.values.flatten()
error
AttributeError: 'list' object has no attribute 'flatten'
当我尝试时:
g1 = np.vectorize(g)
error
TypeError: unsupported operand type(s) for +: 'int' and 'vectorize'
我该怎么办?使用:
g1 = np.array(g).flatten()
输出:
array([ 11, 7, 6, 3, 1, 4, 7, 0, 0, 0, 172])