Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.5k views
in Technique[技术] by (71.8m points)

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

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...