-
-
Notifications
You must be signed in to change notification settings - Fork 19.3k
BUG 55136: add test #63020
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
BUG 55136: add test #63020
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,5 @@ | ||
| from contextlib import redirect_stdout | ||
| import io | ||
| import re | ||
| import warnings | ||
| import weakref | ||
|
|
@@ -1259,3 +1261,18 @@ def test_categorical_nan_no_dtype_conversion(): | |
| expected = pd.DataFrame({"a": Categorical([1], [1]), "b": [1]}) | ||
| df.loc[0, "a"] = np.array([1]) | ||
| tm.assert_frame_equal(df, expected) | ||
|
|
||
|
|
||
| def test_dt_to_pydatetime_conversion(): | ||
| expected = "datetime" | ||
|
|
||
| df = pd.DataFrame({"ts": [pd.Timestamp("2024-01-01 12:00:00").as_unit("ns")]}) | ||
| df["ts"] = df.ts.dt.to_pydatetime() | ||
| assert df["ts"].dtype == expected | ||
|
|
||
| buffer = io.StringIO() | ||
| with redirect_stdout(buffer): | ||
| df.info() | ||
|
|
||
| output = buffer.getvalue() | ||
| assert expected in output | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i think you'll end up with "object" in output
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. Different versions give different result.s |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this test about
infoor thedf["ts"] =call? that will determine what file this belongs inThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is about info()
As described in the issue: a df has a column of type datetime[ns]. After to_pydatetime conversion, the reporter of the issue expects df.info() will show the column changes to datetime type, but still got datetime[ns] type.