Converting datetime string to datetime in numpy (python)

微笑、不失礼 提交于 2019-11-29 06:26:18

So far as I can tell, np.datetime64 only works with

strings in ISO 8601 date or datetime format

The to_datetime function in pandas seems to be more flexible:

import pandas as pd
a=pd.to_datetime(['17-10-2010 07:15:30', '13-05-2011 08:20:35', "15-01-2013 09:09:09"])

Of course you can easily convert back to numpy:

np.array(a,dtype=np.datetime64)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!