我已经成功地在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
我运行的是gspread版本4.0.1。
看起来其他的与这个客户端相关的方法都在工作,但是这个函数不是一个方法。
有没有关于如何让它成功运行的想法?
发布于 2021-08-23 19:04:59
从文档中看不清楚这一点,但看起来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时不需要执行这一步--也许这些包已经预先安装在Google colab上了?
https://stackoverflow.com/questions/68776426
复制相似问题