seaborn stripplot ValueError: Could not interpret input 'OS'

老子叫甜甜 提交于 2019-12-02 03:03:16

问题


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: 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

This is my CSV file:

Dataset

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


回答1:


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)

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.



来源:https://stackoverflow.com/questions/51687122/seaborn-stripplot-valueerror-could-not-interpret-input-os

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!