Reputation: 1
Hi im a little bit stuck here, i'm trying to fill empty dates in a df. This is my code:
change_date["latest_change_at"].fillna("2001-01-01T00:00:00Z", inplace=True)
This is my error:
Value '2001-01-01T00:00:00Z' has dtype incompatible with datetime64[ns], please explicitly cast to a compatible dtype first.
I tried to change the values for the fillna
to datetime64[ns
] by running this:
change_date["latest_change_at"].fillna(np.datetime64('2001-01-01T00:00:00'), inplace=True)
pandas._libs.tslibs.np_datetime.OutOfBoundsDatetime: Cannot cast 2001-01-01 00:00:00 to unit='ns' without overflow.
AssertionError: Did not expect new dtype datetime64[ns] to equal self.dtype datetime64[ns]. Please report a bug at https://github.com/pandas-dev/pandas/issues.
Upvotes: 0
Views: 400
Reputation: 285
The numpy syntax you shared works for me.
can you try this:
df["start_dt"].fillna(pd.to_datetime("2001-01-01",format="%Y-%m-%d"), inplace=True)
Upvotes: 0