Datetime conversion - How to extract the inferred format?

后端 未结 3 894
庸人自扰
庸人自扰 2020-11-30 07:44

Here\'s an array of datetime values:

array = np.array([\'2016-05-01T00:00:59.3+10:00\', \'2016-05-01T00:02:59.4+10:00\',
                  \'2016-05-01T00:03         


        
3条回答
  •  伪装坚强ぢ
    2020-11-30 08:15

    You can use _guess_datetime_format from core.tools to get the format. ie

    from pandas.core.tools import datetimes as tools
    tools._guess_datetime_format(pd.to_datetime(array).format()[0][:10])
    

    Output :

    '%Y-%m-%d'
    

    To know more about this method you can see here. Hope it helps.

提交回复
热议问题