Python ValueError:使用seaborn时,缓冲区的维度数错误(预期为1,实际为2)
我正在尝试使用seaborn绘制计数图。然而,我不断得到错误:Python ValueError:使用seaborn时,缓冲区的维度数错误(预期为1,实际为2),python,numpy,data-visualization,seaborn,Python,Numpy,Data Visualization,Seaborn,我正在尝试使用seaborn绘制计数图。然而,我不断得到错误: ValueError: Buffer has wrong number of dimensions (expected 1, got 2) 数据的数组格式如下所示: kmeans_updated_transform Output : array([[ 69.86249185, 420.73371599, 293.97930338, ..., 75.0959945 , 1324.91
ValueError: Buffer has wrong number of dimensions (expected 1, got 2)
数据的数组格式如下所示:
kmeans_updated_transform
Output : array([[ 69.86249185, 420.73371599, 293.97930338, ..., 75.0959945 ,
1324.91605382, 695.82952194],
[ 653.72679905, 173.0166009 , 881.79444099, ..., 519.62763564,
737.738956 , 114.53013382],
[ 137.60270124, 621.0421363 , 93.48686268, ..., 271.48007915,
1525.69688999, 896.4147582 ],
...,
pca_original_transform
Output: array([[ 9.43214091e+01, -1.89435531e+01, 1.07357663e+01, ...,
1.23508040e-02, -4.93779143e-03, 4.85990628e-13],
[ 6.82436757e+02, 3.43334711e+01, 9.96130809e+00, ...,
1.91267574e-02, 8.14910013e-03, -1.38680181e-13],
[-1.06579511e+02, -6.68715037e+00, -1.84056983e+00, ...,
-1.90794427e-02, -4.22592696e-03, -2.87145744e-13],
...,
最后,我有一个称为cat的数据帧。
这是我正在使用的代码
ax = sns.countplot(x=pca_orignal_transform, hue=kmeans_updated_transform, data=cat)
当我试图绘制计数图时,为什么计数图会抛出错误。任何帮助都将不胜感激。谢谢如果
df
是您的数据帧,则通过将该数据帧中的列名提供给countplot
ax = sns.countplot(x="columnname1", hue="columnname2", data=cat)
您能显示发生异常的代码或部分代码吗?@Shiva我刚刚更新了问题中的代码。请检查您的
cat
数据框中是否有重复的列名。您可能需要阅读并提供此类示例,这样其他人就有机会帮助你了。好吧,如果我只想使用阵列而不想使用df,那怎么办?为什么@重要的是FBEINGERNEST,但如果查看上的参数data
。它说它可以获取一个数组、数据帧或数组列表@ImportanceOfBeingErnestYes,数据
可以是数组。但是hue
不能,如果给出数据
。好的,我正在使用数组名称中的pca数据绘制聚类数据。我该怎么做?有什么建议要使用哪种类型的countplot@当然,我的建议是使用我在这里提供的答案。