seaborn stripplot ValueError: Could not interpret

2019-03-04 23:13发布

问题:

I am new to seaborn(version: '0.9.0'). I loaded my data from a CSV file in pdandas 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.