Skip to content

Commit 4a1b1ba

Browse files
committed
Make default for convert_datetime64=None and adjust tests
1 parent 9837eb0 commit 4a1b1ba

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

doc/source/whatsnew/v0.23.0.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -842,7 +842,7 @@ Deprecations
842842
- ``pandas.tseries.plotting.tsplot`` is deprecated. Use :func:`Series.plot` instead (:issue:`18627`)
843843
- ``Index.summary()`` is deprecated and will be removed in a future version (:issue:`18217`)
844844
- ``NDFrame.get_ftype_counts()`` is deprecated and will be removed in a future version (:issue:`18243`)
845-
- The ``convert_datetime64`` parameter in :func:`DataFrame.to_records` has been deprecated and will be removed in a future version. The NumPy bug motivating this parameter has been resolved (:issue:`18160`).
845+
- The ``convert_datetime64`` parameter in :func:`DataFrame.to_records` has been deprecated and will be removed in a future version. The NumPy bug motivating this parameter has been resolved. The default value for this parameter has also changed from ``True`` to ``None`` (:issue:`18160`).
846846

847847
.. _whatsnew_0230.prior_deprecations:
848848

pandas/core/frame.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1311,7 +1311,7 @@ def from_records(cls, data, index=None, exclude=None, columns=None,
13111311

13121312
return cls(mgr)
13131313

1314-
def to_records(self, index=True, convert_datetime64=False):
1314+
def to_records(self, index=True, convert_datetime64=None):
13151315
"""
13161316
Convert DataFrame to a NumPy record array.
13171317
@@ -1322,7 +1322,7 @@ def to_records(self, index=True, convert_datetime64=False):
13221322
----------
13231323
index : boolean, default True
13241324
Include index in resulting record array, stored in 'index' field.
1325-
convert_datetime64 : boolean, default False
1325+
convert_datetime64 : boolean, default None
13261326
.. deprecated:: 0.23.0
13271327
13281328
Whether to convert the index to datetime.datetime if it is a
@@ -1379,7 +1379,7 @@ def to_records(self, index=True, convert_datetime64=False):
13791379
dtype=[('index', '<M8[ns]'), ('A', '<i8'), ('B', '<f8')])
13801380
"""
13811381

1382-
if convert_datetime64:
1382+
if convert_datetime64 is not None:
13831383
warnings.warn("The 'convert_datetime64' parameter is "
13841384
"deprecated and will be removed in a future "
13851385
"version",

pandas/tests/frame/test_convert_to.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,17 @@ def test_to_records_dt64(self):
8080
["four", "five", "six"]],
8181
index=date_range("2012-01-01", "2012-01-02"))
8282

83-
# convert_datetime64 defaults to False if not passed
83+
# convert_datetime64 defaults to None
8484
expected = df.index.values[0]
8585
result = df.to_records()['index'][0]
8686
assert expected == result
8787

88+
# check for FutureWarning if convert_datetime64=False is passed
89+
with tm.assert_produces_warning(FutureWarning):
90+
expected = df.index.values[0]
91+
result = df.to_records(convert_datetime64=False)['index'][0]
92+
assert expected == result
93+
8894
# check for FutureWarning if convert_datetime64=True is passed
8995
with tm.assert_produces_warning(FutureWarning):
9096
expected = df.index[0]

0 commit comments

Comments
 (0)