Skip to content

Commit 5ff6095

Browse files
authored
BUG 55136: add test
1 parent 00a7c41 commit 5ff6095

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

pandas/tests/dtypes/test_dtypes.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from contextlib import redirect_stdout
2+
import io
13
import re
24
import warnings
35
import weakref
@@ -1259,3 +1261,18 @@ def test_categorical_nan_no_dtype_conversion():
12591261
expected = pd.DataFrame({"a": Categorical([1], [1]), "b": [1]})
12601262
df.loc[0, "a"] = np.array([1])
12611263
tm.assert_frame_equal(df, expected)
1264+
1265+
1266+
def test_dt_to_pydatetime_conversion():
1267+
expected = "datetime"
1268+
1269+
df = pd.DataFrame({"ts": [pd.Timestamp("2024-01-01 12:00:00").as_unit("ns")]})
1270+
df["ts"] = df.ts.dt.to_pydatetime()
1271+
assert df["ts"].dtype == expected
1272+
1273+
buffer = io.StringIO()
1274+
with redirect_stdout(buffer):
1275+
df.info()
1276+
1277+
output = buffer.getvalue()
1278+
assert expected in output

0 commit comments

Comments
 (0)