我想将一个csv文件读入pandas Dataframe ,但得到以下错误
执行此代码时:
filepath = "https://drive.google.com/file/d/1bUTjF-iM4WW7g_Iii62Zx56XNTkF2-I1/view" df = pd.read_csv(filepath) df.head(5)
ovfsdjhp1#
要从Google Drive中检索信息或数据,首先,您需要识别文件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())
bvjxkvbb2#
尝试以下代码片段将CSV从Google Drive读取到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)
2条答案
按热度按时间ovfsdjhp1#
要从Google Drive中检索信息或数据,首先,您需要识别文件ID。
bvjxkvbb2#
尝试以下代码片段将CSV从Google Drive读取到pandas DataFrame中: