Pandas: Datetime Improperly selecting day as month from date [duplicate]

use

pd.to_datetime(data['date'], dayfirst=True)

since the day comes obviously first in your data but pandas assumes month first by default.

docs – “dayfirst : bool, default False

Note: evaluation of day first / last is not strict, i.e. it is evaluated line by line – which is why you get such mixed results but no error.

Leave a Comment