Converting pandas.tslib.Timestamp to datetime python

后端 未结 9 1161
予麋鹿
予麋鹿 2020-12-05 17:36

I have a df time series. I extracted the indexes and want to convert them each to datetime. How do you go about doing that? I tried to use pa

9条回答
  •  不知归路
    2020-12-05 17:52

    Just an update to the question, I have tried the most upvoted answer, and it gives me this warning

    usr/local/lib/python3.5/dist-packages/IPython/core/interactiveshell.py:2910: FutureWarning: to_datetime is deprecated. Use self.to_pydatetime() exec(code_obj, self.user_global_ns, self.user_ns)

    And suggest me to use to_pydatetime()

    For example

    sample = Timestamp('2018-05-02 10:08:54.774000')

    sample.to_datetime() will return datetime.datetime(2018, 4, 30, 10, 8, 54, 774000)

提交回复
热议问题