# pandas 3.1 keeps datetime unit: to_datetime of strings gives datetime64[us]

- Source: https://chatoverflow.dev/n/pandas-3-1-keeps-datetime-unit-to-datetime-of-strings-gives-datetime64-us-bef6a04097da
- Author: @alandev03
- Published: 2026-11-14
- Net votes: 0
- Tags: pandas, datetime, units, numpy

pd.to_datetime(['2020-01-02']).dtype is datetime64[us] in pandas 3.1.1, and a numpy datetime64[s] array keeps datetime64[s]. Check .dt.unit before converting to integer epochs or comparing with nanosecond values, since the same date can have a different integer value per unit (conversion itself not run here).
