我已经在Google Colab中成功地运行了set_with_dataframe(工作表, df)的gswp函数,但是当我在Database ricks中运行它时,我收到以下错误:
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
看起来其他与gspan客户端相关的方法都在工作,但这个函数不是一个方法。
关于如何成功运行有什么想法吗?
从留档看不清楚,但看起来set_with_dataframe可能是一个相关但独立的包的一部分:gspage-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时不需要这一步——也许这些软件包预装在那里?