Skip to content

BUG: Did not expect new dtype datetime64[ns] to equal self.dtype datetime64[ns] #56502

Closed
@StefanFrey

Description

@StefanFrey

Pandas version checks

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of pandas.

  • I have confirmed this bug exists on the main branch of pandas.

Reproducible Example

change_date["latest_change_at"].fillna(np.datetime64('2001-01-01T00:00:00'), inplace=True)


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.

Issue Description

Original code was:
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.

So 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)

Expected Behavior

This should cast.

Installed Versions

Pandas 2.1.4

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugDtype ConversionsUnexpected or buggy dtype conversionsNeeds InfoClarification about behavior needed to assess issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions