简体   繁体   English

ValueError:使用Seaborn时,缓冲区的维数错误(预期为1,为2)

[英]ValueError: Buffer has wrong number of dimensions (expected 1, got 2) when using seaborn

I am trying to plot a count plot using seaborn. 我正在尝试使用seaborn绘制计数图。 However, I keep getting the error: 但是,我不断收到错误:

 ValueError: Buffer has wrong number of dimensions (expected 1, got 2)

The data is in array format like this: 数据采用如下数组格式:

      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],
       ...,

Finally, I have a data frame known as cat. 最后,我有一个称为cat的数据框。 This is the code I am using 这是我正在使用的代码

ax = sns.countplot(x=pca_orignal_transform, hue=kmeans_updated_transform, data=cat)

Why is the count plot throwing an error when I try to plot it. 为什么在尝试绘制计数图时会抛出错误。 Any help would be appreciated. 任何帮助,将不胜感激。 Thanks 谢谢

如果df是您的数据帧,则通过将该数据帧的列名提供给countplot的参数来countplot

ax = sns.countplot(x="columnname1", hue="columnname2", data=cat)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 熊猫:“ ValueError:缓冲区的维数错误(预期1,得到0) - Pandas: "ValueError: Buffer has wrong number of dimensions (expected 1, got 0) ValueError:如果在语句中,则缓冲区的维数错误(预期为1,得到2) - ValueError: Buffer has wrong number of dimensions (expected 1, got 2) on if in statement Pandas ValueError:缓冲区的维数错误(预期为 1,得到 2) - Pandas ValueError: Buffer has wrong number of dimensions (expected 1, got 2) Cython ValueError:缓冲区的维数错误(预期2,得3) - Cython ValueError: Buffer has wrong number of dimensions (expected 2, got 3) 缓冲区的维数错误(预期为 1,得到 2) - Buffer has wrong number of dimensions (expected 1, got 2) pandas:使用 hstack 时缓冲区的维数错误(预期为 1,得到 2) - pandas: Buffer has wrong number of dimensions (expected 1, got 2) when using hstack 在创建 pandas DataFrame ValueError: Buffer has wrong number of dimensions (expected 1, got 2) - during creation of pandas DataFrame ValueError: Buffer has wrong number of dimensions (expected 1, got 2) df.loc - ValueError:缓冲区的维数错误(预期为 1,得到 0) - df.loc - ValueError: Buffer has wrong number of dimensions (expected 1, got 0) pd.insert ValueError:缓冲区的维数错误(预期为 1,得到 2) - pd.insert ValueError: Buffer has wrong number of dimensions (expected 1, got 2) Python scikits - 缓冲区的维数错误(预期1,得2) - Python scikits - Buffer has wrong number of dimensions (expected 1, got 2)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM