How to remove timezone from a Timestamp column in a pandas dataframe

前端 未结 1 1001
星月不相逢
星月不相逢 2020-11-27 19:52

I read Pandas change timezone for forex DataFrame but I\'d like to make the time column of my dataframe timezone naive for interoperability with an sqlite3 database.

相关标签:
1条回答
  • 2020-11-27 20:46

    The column must be a datetime dtype, as from using pd.to_datetime, then you can use tz_localize to change the time zone, a naïve timestamp corresponds to time zone None:

    testdata['time'].dt.tz_localize(None)
    

    Unless the column is an index (DatetimeIndex), the .dt accessor must be used to access pandas datetime functions.

    0 讨论(0)
提交回复
热议问题