File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change 1+ from contextlib import redirect_stdout
2+ import io
13import re
24import warnings
35import 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
You can’t perform that action at this time.
0 commit comments