seaborn stripplot ValueError:无法解释输入“OS" [英] seaborn stripplot ValueError: Could not interpret input 'OS'

查看:63
本文介绍了seaborn stripplot ValueError:无法解释输入“OS"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 seaborn 的新手(版本:'0.9.0').我从 Pandas 中的 CSV 文件加载了我的数据,但是当我尝试创建条带图时,我收到此错误:

I am new to seaborn(version: '0.9.0'). I loaded my data from a CSV file in pandas but when I am trying to create the stripplot i get this error:

ValueError: 无法解释输入OS"

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()

代码错误

这是我的 CSV 文件:

This is my CSV file:

数据集

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

This is the link to the CSV file: The CSV File

推荐答案

出于某种原因,csv 文件中的某些列附加了一个空格.这意味着您需要使用例如访问它们"OS " 而不是 "OS".因此,以下将起作用:

For some reason some columns in the csv file have a blank space appended. This means that you need to access them with e.g. "OS " instead of "OS". The following would hence work:

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

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

The more reliable way is of course to sanitize your input data prior to loading it. I.e. run a search/replace and replace " ," by "," in the file.

这篇关于seaborn stripplot ValueError:无法解释输入“OS"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆