Pandas DataFrame.to_sql automatically adds FixedOffsetTimezone to dataframe. My initial dataframe index doesnt have timezone:
However, when I try to save dataframe and retrieve values, returned index has timezone -4:
Does anyone know how to turn it off? Pandas documentation doesnt mention it dataframe.to_sql
ats.all.to_sql("ats_all", con, if_exists="replace")
where con=SQL Alchemy connection
Database=Postgres with pgAdmin 4
I found the solution: the problem was indeed in the postgres settings. Database timezone was set to -4. Here's the sql to set timezone to 0
--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';
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.