简体   繁体   English

为什么 Google Colab 会在读取 csv 时引发错误,而 jupyter notebook 不会?

[英]Why is Google Colab raising an error for reading in a csv and jupyter notebook isn't?

I'm receiving this error when attempting to read in csv data using python and pandas.尝试使用 python 和 pandas 读取 csv 数据时收到此错误。 I don't experience this error in Jupyter notebooks but I'm trying to use google colab and experience the error there.我在 Jupyter 笔记本中没有遇到此错误,但我正在尝试使用 google colab 并在那里遇到错误。 Any ideas why google colab is raising the error but jupyter isn't?任何想法为什么 google colab 引发错误但 jupyter 不是?

df = pd.read_csv('./final_data_for_modeling.csv')

---------------------------------------------------------------------------
ParserError                               Traceback (most recent call last)
<ipython-input-7-3a755ce18082> in <module>()
      2 
      3 # Load the dataset into a pandas dataframe.
----> 4 df = pd.read_csv('./final_data_for_modeling.csv')


ParserError: Error tokenizing data. C error: Expected 1 fields in line 3, saw 2

For contrast here is a screenshot of the success in jupyter作为对比,这里是 jupyter 成功的截图

jupyter 成功截图

If you'd like to take a look at the csv here is a dropbox link to the data:如果您想查看 csv,这里是数据的保管箱链接:

https://www.dropbox.com/s/i3od76b52t19vzr/final_data_for_modeling.csv?dl=0 https://www.dropbox.com/s/i3od76b52t19vzr/final_data_for_modeling.csv?dl=0

This works out of the box for me.这对我来说是开箱即用的。 Here's a complete notebook: https://colab.research.google.com/drive/1CATW8DtNh9wZTKpp5bV2DqfU6ChkFgty这是一个完整的笔记本: https : //colab.research.google.com/drive/1CATW8DtNh9wZTKpp5bV2DqfU6ChkFgty

Full code & output:完整代码和输出: 在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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