python-3.6 - seaborn stripplot ValueError : Could not interpret input 'OS'

标签 python-3.6 seaborn

我是seaborn的新手(版本:'0.9.0')。 我从 pandas 中的 CSV 文件加载了数据,但是当我尝试创建条形图时,出现此错误:

ValueError: Could not interpret input 'OS'

import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
import seaborn as sb
smartphones = pd.read_csv('D:\\Python Codes\\DataScience\\Smartphone.csv')
sb.stripplot(x='OS',y='Capacity',data=smartphones,size=10, jitter=True)
plt.show()

CodeError

这是我的 CSV 文件:

Dataset

这是 CSV 文件的链接: The CSV File

最佳答案

出于某种原因,csv 文件中的某些列附加了空格。这意味着您需要通过以下方式访问它们: “操作系统” 而不是“操作系统”。因此,以下内容将起作用:

sb.stripplot(x='OS ',y='Capacity ',data=smartphones,size=10, jitter=True)

更可靠的方法当然是在加载输入数据之前对其进行清理。 IE。运行搜索/替换,并将文件中的 "," 替换为 ","

关于python-3.6 - seaborn stripplot ValueError : Could not interpret input 'OS' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51687122/

相关文章:

python - cv2.dnn' 使用 python 3.6 和 opencv3.4.1 没有属性 'readNet'

python - 将字符串和整数分割为特定长度的python

Python2.7 : How to create bar graph using index and column information?

python - 如何在seaborn对象api中定义带有rgb值的颜色?

python - Python 中的seaborn : barplot appears upside down

python3 - 从异步方法获取结果

azure - 为什么我无法通过 powershell 脚本运行 python 命令?

python - 如何将我表上的 fetchall() 的输出限制为仅值?

python-3.x - 如何更改 Seaborn 数据标签以显示两位小数

Python:在 Seaborn 中更改/自定义颜色图