[英]pandas dataframe.to_sql turn off automatic timezone offset
Pandas DataFrame.to_sql automatically adds FixedOffsetTimezone to dataframe. Pandas DataFrame.to_sql 自动将 FixedOffsetTimezone 添加到数据帧。 My initial dataframe index doesnt have timezone:
我的初始数据帧索引没有时区:
However, when I try to save dataframe and retrieve values, returned index has timezone -4:但是,当我尝试保存数据帧并检索值时,返回的索引的时区为 -4:
Does anyone know how to turn it off?有谁知道怎么关掉? Pandas documentation doesnt mention it dataframe.to_sql
Pandas 文档没有提到它dataframe.to_sql
ats.all.to_sql("ats_all", con, if_exists="replace")
where con=SQL Alchemy connection其中 con=SQL Alchemy 连接
Database=Postgres with pgAdmin 4 Database=Postgres with pgAdmin 4
I found the solution: the problem was indeed in the postgres settings.我找到了解决方案:问题确实出在 postgres 设置中。 Database timezone was set to -4.
数据库时区设置为 -4。 Here's the sql to set timezone to 0
这是将时区设置为 0 的 sql
--check current timezone setting
SELECT current_setting('TIMEZONE');
--need to restart database for the change to kick in
ALTER DATABASE postgres SET timezone TO 'GMT';
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.