简体   繁体   English

使用 df2gspread 上传 pandas DataFrame 时,如何防止将我的索引上传到 Google 表格?

[英]How do I prevent uploading my index to Google Sheets when uploading a pandas DataFrame using df2gspread?

I'm trying to upload a DataFrame to Google Sheets using the df2gspread library.我正在尝试使用 df2gspread 库将 DataFrame 上传到 Google 表格。 The upload is successful, however, it also uploads the index of my DataFrame.上传成功了,不过也上传了我的DataFrame的索引。 Is there anyway to not have the index of my dataframe be included in the upload?无论如何,我的 dataframe 的索引是否不包含在上传中?

My code:我的代码:

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

My Spreadsheet:我的电子表格:

https://gyazo.com/492838f2c5f8d8b05df3365e5f206186 https://gyazo.com/492838f2c5f8d8b05df3365e5f206186

Thank you to @Chris for your comment.感谢@Chris 的评论。 I needed to set row_names to False.我需要将 row_names 设置为 False。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用 df2gspread 将多索引 dataframe 上传到谷歌表格 - Uploading a multiindex dataframe to google sheets using df2gspread 将 DF 上传到 Google 表格时出现 df2gspread 类型错误 - df2gspread Type Error when uploading DF to Google sheets "InvalidClientSecretsError - df2gspread - Panda - Google 表格" - InvalidClientSecretsError - df2gspread - Panda - Google Sheet 通过Gspread将.csv上传到Google表格 - Uploading .csv to Google Sheets via Gspread MultiIndex pandas dataframe 并使用 gspread-pandas 写入 Google 表格 - MultiIndex pandas dataframe and writing to Google Sheets using gspread-pandas 将 pandas dataframe 上传到谷歌电子表格 - Uploading pandas dataframe to google spreadsheet 使用python将数据框上传到Google表格时出错? - Error while uploading dataframe to google sheets using python? 使用 JSON 序列化/反序列化 Pandas DataFrame 时如何保持索引的时区 - How do I keep the timezone of my index when serializing/deserializing a Pandas DataFrame using JSON 如何使用 gspread 缓存 Google 表格的授权? - How to cache authorization for Google Sheets using gspread? 熊猫数据框索引在索引数据框的子集时引起问题。 如何删除索引,或防止发生错误? - Pandas dataframe index causing problems when indexing subset of dataframe. How do I remove the indexes, or prevent the error from occurring?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM