Converting pandas.tslib.Timestamp to datetime python

后端 未结 9 1146
予麋鹿
予麋鹿 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:57

    In my case I could not get a correct output even when specifying the format: I used to get always the year 1970.

    Actually what solved my problem was to specify the unit parameter to the function since my timestamps have seconds granularity:

    df_new = df
    df_new['time'] = pandas.to_datetime(df['time'], unit='s')
    

提交回复
热议问题