读取csv中的colab错误

时间:2020-05-15 10:24:00

标签: google-colaboratory

我正在尝试将文件导入c-lab。我尝试过各种版本https://buomsoo-kim.github.io/colab/2018/04/15/Colab-Importing-CSV-and-JSON-files-in-Google-Colab.md/

#import packages
import pandas as pd
pd.plotting.register_matplotlib_converters()
import matplotlib.pyplot as plt
%matplotlib inline
import seaborn as sns
import io
print("Setup Complete")

from google.colab import files
uploaded = files.upload()

# Read the file into a variable power_data
#power_data = pd.read("DE_power prices historical.csv")
data = pd.read_csv('DE_power prices historical.csv', error_bad_lines=False)

继续出现错误: enter image description here

1 个答案:

答案 0 :(得分:0)

尝试使用此方法会更容易一些:

  1. 将.csv文件上传到您的Google云端硬盘
  2. 在Colab单元中运行以下代码:

    from google.colab import drive
    drive.mount('/content/drive')
    
  3. 按照输出单元格为您提供的链接,并验证您的Gmail帐户

  4. 使用Pandas导入:

    power_data = pd.read_csv('/content/drive/My Drive/*filename.csv*')