Skip to content

Commit d195ece

Browse files
committed
convert_datetime64 defaults to True if not passed
1 parent c063f22 commit d195ece

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

pandas/core/frame.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1361,6 +1361,8 @@ def to_records(self, index=True, convert_datetime64=None):
13611361
"deprecated and will be removed in a future "
13621362
"version",
13631363
FutureWarning, stacklevel=2)
1364+
else:
1365+
convert_datetime64 = True
13641366

13651367
if index:
13661368
if is_datetime64_any_dtype(self.index) and convert_datetime64:

pandas/tests/frame/test_convert_to.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,17 @@ def test_to_records_dt64(self):
7979
df = DataFrame([["one", "two", "three"],
8080
["four", "five", "six"]],
8181
index=date_range("2012-01-01", "2012-01-02"))
82+
8283
with tm.assert_produces_warning(FutureWarning):
8384
expected = df.index[0]
8485
result = df.to_records(convert_datetime64=True)['index'][0]
8586
assert expected == result
8687

88+
expected = df.index[0]
89+
# convert_datetime64 defaults to True if not passed
90+
result = df.to_records()['index'][0]
91+
assert expected == result
92+
8793
with tm.assert_produces_warning(FutureWarning):
8894
rs = df.to_records(convert_datetime64=False)
8995
assert rs['index'][0] == df.index.values[0]

0 commit comments

Comments
 (0)