首页 > 解决方案 > 使用 df2gspread 上传 pandas DataFrame 时,如何防止将我的索引上传到 Google 表格?

问题描述

我正在尝试使用 df2gspread 库将 DataFrame 上传到 Google 表格。上传成功,但是,它也上传了我的DataFrame的索引。无论如何,我的数据框的索引是否不包含在上传中?

我的代码:

spreadsheet_key = '1Rg1AUhwz771Rt8LYNtmdgTfeXZdYVNT5o8sW3nlkUQg'
wks_name = 'Master'
d2g.upload(df_result, spreadsheet_key, wks_name, row_names=True)

我的电子表格:

https://gyazo.com/492838f2c5f8d8b05df3365e5f206186

标签: pythonpandasgoogle-sheets

解决方案


感谢@Chris 的评论。我需要将 row_names 设置为 False。


推荐阅读