简体   繁体   English

python df2gspread.d2g.upload:如何上传数据类型为 integer 的 datefram 列

[英]python df2gspread.d2g.upload: How can I upload datefram column with data type integer

is there any way I can use the d2g upload data frame without change all the data type to string?有什么方法可以在不将所有数据类型更改为字符串的情况下使用 d2g 上传数据框? enter image description here在此处输入图像描述

enter image description here在此处输入图像描述

the data type changed when I uploaded it to google sheet, how can I keep the original data type.当我将它上传到谷歌表格时数据类型发生了变化,我怎样才能保持原始数据类型。

I got the exact same problem.我遇到了完全相同的问题。 You should try using gspread-pandas instead.您应该尝试改用 gspread-pandas。 In my experience it works a lot faster than d2g.以我的经验,它的运行速度比 d2g 快得多。 The installation guide is here安装指南在这里

First, you should put your credentials file in the right directory.首先,您应该将凭证文件放在正确的目录中。 If you don't know where it is, you can try this如果你不知道它在哪里,你可以试试这个

from gspread_pandas import Spread
x= Spread(work_sheet_id, worksheet_name)

An error message will show up and tell you where the directory is and that you should rename your credentials as google_secret.json and put it there.将显示一条错误消息并告诉您目录在哪里,您应该将您的凭据重命名为 google_secret.json 并将其放在那里。

After that you can upload into an existing sheet or create a new one:之后,您可以上传到现有工作表或创建新工作表:

x.df_to_sheet(df, index=False, sheet=worksheet_name, replace=True)

The documentation is here if you want to find out more about what parameter values you should use.如果您想了解有关应使用哪些参数值的更多信息,请参阅此处的文档。

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

相关问题 如何使用 gspread 上传到工作表 2 - How to upload to sheet 2 using gspread Python/Gspread 如何在创建工作表时添加列名? - Python/Gspread How can I add column names while creating a worksheet? Python,gspread。 我如何剪切或解析我的列表 - Python, gspread. How i can cut or parse my list 如何确定 df1 中 column1 的值包含在 df2 中的 column1 中(python) - How can I determine that the value of column1 in df1 contains in column1 in df2 (python) 如何将 gspread api 中的数据格式化为 Google 表格 - How can I format data from gspread api into Google Sheets 在Python中,如何将字典转换为df列,其中键与df.index值匹配? - In Python, how can I transform a dictionary into a df column, where the keys match the df.index values? 如何在 gspread 中 append 新工作表并上传本地 CSV - How to append a new worksheet and upload a local CSV in gspread (gspread) 如何使用 gspread 将自定义公式放入单元格中? - (gspread) How can I put a custom formula into a cell using gspread? 如何使用Flask,postgres和Python上传一个csv文件并将数据输入数据库? - how can I upload a csv file and enter the data into a database, using Flask, postgres and Python? 如何使用 DolphinDB Python API 上传 DATETIME 数据 - How do I upload DATETIME data with DolphinDB Python API
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM