Can't convert dates to datetime64

前端 未结 1 1130
长情又很酷
长情又很酷 2021-01-04 02:03

The following piece of code:

import pandas as pd
import numpy as np

data = pd.DataFrame({\'date\': (\'13/02/2012\', \'14/02/2012\')})
data[\'date\'] = data[         


        
相关标签:
1条回答
  • 2021-01-04 02:33

    Do this instead. Pandas keeps datestimes internally as datetime64[ns]. Conversions like this are very buggy (because of issues in various numpy version, 1.6.2 especially). Use the pandas routines, then operate like thesee are actual datetime objects. What are you trying to do?

    In [30]: pandas.to_datetime(data['date'])
    Out[30]: 
    0   2012-02-13 00:00:00
    1   2012-02-14 00:00:00
    Name: date, dtype: datetime64[ns]
    
    0 讨论(0)
提交回复
热议问题