为什么Google Colab引发在csv和jupyter笔记本中无法读取的错误?

时间:2020-02-16 17:35:42

标签: python pandas csv google-colaboratory

当我尝试使用python和pandas读取csv数据时收到此错误。我在Jupyter笔记本中没有遇到此错误,但是我正尝试使用google colab并在那里遇到错误。为什么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

为对比起见,这是jupyter成功的屏幕截图

Screenshot of the success in jupyter

如果您想看一看csv,这里是指向数据的保管箱链接:

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

1 个答案:

答案 0 :(得分:1)

这对我来说是开箱即用的。这是一个完整的笔记本: https://colab.research.google.com/drive/1CATW8DtNh9wZTKpp5bV2DqfU6ChkFgty

完整代码和输出: enter image description here