[英]pandas dataframe.to_sql turn off automatic timezone offset
Pandas DataFrame.to_sql 自動將 FixedOffsetTimezone 添加到數據幀。 我的初始數據幀索引沒有時區:
但是,當我嘗試保存數據幀並檢索值時,返回的索引的時區為 -4:
有誰知道怎么關掉? Pandas 文檔沒有提到它dataframe.to_sql
ats.all.to_sql("ats_all", con, if_exists="replace")
其中 con=SQL Alchemy 連接
Database=Postgres with pgAdmin 4
我找到了解決方案:問題確實出在 postgres 設置中。 數據庫時區設置為 -4。 這是將時區設置為 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.