I have a column in a DataFrame consiting of string of the form '2023-01-12'
. Usually, this column can be parsed by
pd.to_datetime(df['dates'],format='%Y-%m-%d')
or even
pd.to_datetime(df['dates'])
However, I have dates in there which are a long time ago, for example '1444-02-20'
. This results in a OutOfBoundsDatetime
exception. The reason is because pandas tries to parse it with a ns precision. A daily precision would be enough for my purpose. How do I use another precision to make the parsing work?