尝试从本地机器导入google colab中的csv文件

问题描述 投票:0回答:1
from google.colab import files
uploaded = files.upload()
tweets  = pd.read_csv(io.StringIO(uploaded['Tweets.csv']).decode('utf-8'), sep = ';')

我正在尝试导入我的数据,但出现以下错误:

initial_value must be str or None, not bytes
python google-colaboratory
1个回答
0
投票

要给出评论中暗示的完整答案,应该是:

from google.colab import files
import pandas as pd
import io

uploaded = files.upload()
df = pd.read_csv(io.BytesIO(uploaded[`Tweets.csv`]))
© www.soinside.com 2019 - 2024. All rights reserved.