【问题标题】:how to place output data-frame in D2 instead of A1 in google sheets with gspread python如何使用 gspread python 将输出数据帧放置在 D2 而不是 Google 表格中的 A1
【发布时间】:2020-06-09 16:07:11
【问题描述】:
# accessing workbook
wb = gc.open_by_url('https://docs.google.com/spreadsheets/d/1LcFa9PDSjaL-Po47okWzLaUC4QUdtRSXzrgslTo6V7E/edit#gid=0')

# creating new worksheet
worksheet = wb.add_worksheet(title="A_worksheet", rows="100", cols="20")

# print df in new worksheet
sh = wb.worksheet('A_worksheet')
set_with_dataframe(sh, df)

【问题讨论】:

    标签: python pandas google-sheets gspread


    【解决方案1】:

    我刚刚浏览了set_with_dataframe 的源代码。您可以将rowcol 作为参数传递,默认值为1,因此它写入的位置。尝试传递适当的值并检查。

    def set_with_dataframe(worksheet,
                           dataframe,
                           row=1,
                           col=1,
                           include_index=False,
                           include_column_header=True,
                           resize=False,
                           allow_formulas=True):
    

    希望对您有所帮助。

    【讨论】:

    • 感谢它的工作,实际上我只使用了行和列参数
    • 很高兴听到它正在工作。如果您认为该答案有帮助,请考虑通过单击答案旁边的勾号来接受该答案。
    猜你喜欢
    • 2020-08-07
    • 2017-06-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-01-26
    • 1970-01-01
    • 1970-01-01
    • 2019-03-24
    相关资源
    最近更新 更多