python - Seaborn 的 No numeric types to aggregate 错误

标签 python pandas seaborn

我有一个这种形式的 Pandas 数据框:

    Country     Year        Value
0   Thailand    1989       48587.03
1   Thailand    1990       55903.07
2   Vietnam     1989      100290.04
3   Vietnam     1990      118873.59
4   India       1989      147383.02
5   India       1990      178230.05

Value 中值的 dtype 是 float。

我正在使用 seaborn 来漂浮它:

sns.lineplot(x='Year', y='Value', hue='Country', data=topfiveot)

出现错误:

DataError: No numeric types to aggregate

可能是什么导致了这个问题?

最佳答案

我认为这个错误更多地与 pandas.groupby() 有关,而不是与 seaborn 本身有关。检查以确保我所有的数字列都是 float 对我有用。在你的情况下

df.Year = df.Year.astype(float)df.Values = df.Values.astype(float)

关于python - Seaborn 的 No numeric types to aggregate 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54374515/

相关文章:

python - 循环模式下的 Sikuli

python - 当 chunksize = 100 时,大(600 万行)pandas df 导致内存错误 `to_sql `,但可以轻松保存 100,000 个没有 chunksize 的文件

python - 根据文本版本控制删除重复项

python - 字数列表无法重命名列名称

python-3.x - Python find.line 不从文本文件中过滤日期字符串

python - 如何在 seaborn fiddle 情节中为每个组分配不同的位置

python - 子图未正确填充

python - 替换已弃用的 tsplot

python - 如何取消 PKCS#7/PKCS#5 填充?

python - 如何在 C 中编写一个函数,它将两个矩阵作为 numpy 数组的输入