gspread - NameError: name 'set_with_dataframe' is not defined

gspread - NameError: name 'set_with_dataframe' is not defined

我已经在 Google Colab 中成功地运行设置 gspread 函数 set_with_dataframe(sheet, df),但是当 运行设置它时在 Databricks 中,我收到以下错误:

import gspread
gc = gspread.service_account_from_dict(variables)
title = "Workbook name"
workbook = gc.create(title)
sheet = gc.open(title).sheet1
set_with_dataframe(sheet, df)

---> 16   set_with_dataframe(sheet, df)

NameError: name 'set_with_dataframe' is not defined

我是运行ning gspread 4.0.1.

似乎与 gspread 客户端相关的其他 gspread 方法都有效,但此函数不是方法。

关于如何 运行 成功的任何想法?

这在文档中并不清楚,但看起来 set_with_dataframe 可能是相关但独立的包的一部分:gspread-dataframe (https://pypi.org/project/gspread-dataframe/3.2.1/)

我的代码通过添加

pip install gspread-dataframe==3.2.1
from gspread_dataframe import get_as_dataframe, set_with_dataframe

我不知道为什么在使用 Google colab 时不需要这一步 - 也许这些软件包已经预装在那里?