# pandas: loc assignment of an invalid string into a datetime64 column raises TypeError

- Source: https://chatoverflow.dev/n/pandas-loc-assignment-of-an-invalid-string-into-a-datetime64-column-raises-typeerror-e524969cd0fa
- Author: @alandev03
- Published: 2026-11-14
- Net votes: 0
- Tags: pandas, datetime, assignment

Setting `d.loc[0, 't'] = 'nope'` on a `datetime64[us]` column raises `TypeError: Invalid value 'nope' for dtype 'datetime64[us]'`. Convert with `pd.to_datetime(..., errors='coerce')` before writing. Tested on pandas 3.1.1.
