将 csv 文件读入 python pandas

reading csv file into python pandas

我想将 csv 文件读入 pandas 数据框,但在执行以下代码时得到 error:

filepath = "https://drive.google.com/file/d/1bUTjF-iM4WW7g_Iii62Zx56XNTkF2-I1/view"
df = pd.read_csv(filepath)
df.head(5)

尝试使用以下代码片段从 Google Drive 读取 CSV 到 pandas DataFrame:

import pandas as pd

url = "https://drive.google.com/uc?id=1bUTjF-iM4WW7g_Iii62Zx56XNTkF2-I1"
df = pd.read_csv(url)
df.head(5)

要从 google 驱动器中检索信息或数据,首先,您需要识别文件 ID。

import pandas as pd

url='https://drive.google.com/file/d/0B6GhBwm5vaB2ekdlZW5WZnppb28/view?usp=sharing'
file_id=url.split('/')[-2]
dwn_url='https://drive.google.com/uc?id=' + file_id
df = pd.read_csv(dwn_url)
print(df.head())