简体   繁体   中英

Jupyter Notebook - Pandas

在此处输入图片说明 在此处输入图片说明 I am new to using Jupyter, NumPy, and pandas. I was looking for a solution online but I could not find anything to solve the error.

I am trying to load a file.csv but I got an error each time I find a solution. I also tried to upload the file to Jupyter notebook to use just the file directly but my system respond that the file is not there. I convert the file from .txt to .csv assuming that that was the problem but still can't load directly. Thus, I decided to use the long format but still have problems.

data = pd.read_csv(r'C:/Users/kharm/Dropbox/Jupyter/Assignment/AutoInsurSweden.csv', header=None)
data.head()

I got the error:

ParserError: Error tokenizing data. C error: Expected 1 field in line 12, saw 2

If I modify to:

data = pd.read_csv(r'C:/Users/kharm/Dropbox/Jupyter/Assignment/AutoInsurSweden.csv', header=None, error_bad_lines=False )
data.head()

or

data = pd.read_csv(r'C:/Users/kharm/Dropbox/Jupyter/Assignment/AutoInsurSweden.csv', header=None, sep='\n')
data.head()

该错误表明问题在于数据文件本身而不是您的代码,似乎在 csv 的第 12 行您有一个额外的数据字段

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM