简体   繁体   English

将 DF 上传到 Google 表格时出现 df2gspread 类型错误

[英]df2gspread Type Error when uploading DF to Google sheets

I'm getting the following error when trying to use d2g.upload() to save a DF back to a Google sheet:尝试使用 d2g.upload() 将 DF 保存回 Google 工作表时出现以下错误:

TypeError: '<' not supported between instances of 'str' and 'int' TypeError:“str”和“int”的实例之间不支持“<”

It is saving the index and the DF column names to the Google sheet, but not actually populating the data into the sheet.它将索引和 DF 列名称保存到 Google 工作表中,但实际上并未将数据填充到工作表中。

No idea what's causing it, has anyone else encountered this same problem?不知道是什么原因造成的,有没有其他人遇到过同样的问题? Below is the code I'm using to save the DF back to Google sheets.下面是我用来将 DF 保存回 Google 表格的代码。 I've used the same code for several other DF's and it works, I just don't know what's unique and this specific DF that's causing the issue.我对其他几个 DF 使用了相同的代码并且它有效,我只是不知道什么是独特的以及导致问题的特定 DF。 The Dtypes are all object / float. Dtypes 都是 object / float。 Any help would be greatly apprecaited!任何帮助将不胜感激!

from df2gspread import df2gspread as d2g 
wks_name = 'Linkedin_Campaign_Ad_Daily_Clean'

d2g.upload(li_ad_link_clicks, spreadsheet_key, wks_name, credentials=credentials, row_names=True)

I fixed this by deleting duplicate columns in my dataframe:我通过删除 dataframe 中的重复列来解决此问题:

df = df.loc[:,~df.columns.duplicated()] df = df.loc[:,~df.columns.duplicated()]

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

相关问题 使用 df2gspread 将多索引 dataframe 上传到谷歌表格 - Uploading a multiindex dataframe to google sheets using df2gspread 使用 df2gspread 上传 pandas DataFrame 时,如何防止将我的索引上传到 Google 表格? - How do I prevent uploading my index to Google Sheets when uploading a pandas DataFrame using df2gspread? "InvalidClientSecretsError - df2gspread - Panda - Google 表格" - InvalidClientSecretsError - df2gspread - Panda - Google Sheet 通过Gspread将.csv上传到Google表格 - Uploading .csv to Google Sheets via Gspread 将空熊猫DF与Google表格中单独DF的行合并 - Merging empty pandas DF with rows from separate DF on Google Sheets 使用 gspread 和 gspread_dataframe 从 Google 表格导入数据时强制使用特定的单元格类型 - Force a specific cell type when importing data from Google sheets with gspread and gspread_dataframe 使用 google_trans_new 库翻译 python 中的 df 时出错 - error when translating a df in python with google_trans_new library KeyError:将数据上传到df之前的代码错误 - KeyError: code error before uploading data to df 授权 Google Drive 服务帐户将 pandas df 写入 Google 表格 - Authorizing Google Drive service account to write pandas df to Google Sheets python df2gspread.d2g.upload:如何上传数据类型为 integer 的 datefram 列 - python df2gspread.d2g.upload: How can I upload datefram column with data type integer
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM