Skip to content

Conversation

dcamejo1
Copy link

@dcamejo1 dcamejo1 commented Oct 15, 2025

@dcamejo1
Copy link
Author

@WillAyd Removed description comments as mentioned, thanks for feedback!

assert isinstance(df["time"].dtype, pd.DatetimeTZDtype)
assert str(df["time"].dtype.tz) == "UTC"

expected_time = Timestamp(_time)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
expected_time = Timestamp(_time)

expected = DataFrame(
{
"id": [1, 2, 3],
"time": [pd.NaT, expected_time, expected_time],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"time": [pd.NaT, expected_time, expected_time],
"time": [pd.NaT, _time, _time],

The issue is about the Python datetime type - we don't want to wrap it with Timestamp

"time": [pd.NaT, expected_time, expected_time],
}
)
expected["time"] = expected["time"].astype("datetime64[us, UTC]")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
expected["time"] = expected["time"].astype("datetime64[us, UTC]")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BUG: enlarging a DataFrame by adding an extra column with a tz-aware datetime results in object dtype

2 participants