diff --git a/doc/source/whatsnew/v0.23.0.txt b/doc/source/whatsnew/v0.23.0.txt index 345ac002ddfbf..c243afea8fd9f 100644 --- a/doc/source/whatsnew/v0.23.0.txt +++ b/doc/source/whatsnew/v0.23.0.txt @@ -219,7 +219,7 @@ Deprecations - ``Series.valid`` is deprecated. Use :meth:`Series.dropna` instead (:issue:`18800`). - :func:`read_excel` has deprecated the ``skip_footer`` parameter. Use ``skipfooter`` instead (:issue:`18836`) - The ``is_copy`` attribute is deprecated and will be removed in a future version (:issue:`18801`). -- The ``convert_datetime64`` parameter in :func:`DataFrame.to_records` has been deprecated and the default value is now ``False``. The NumPy bug motivating this parameter has been resolved (:issue:`18160`). +- 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`). .. _whatsnew_0230.prior_deprecations: diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 3779f3c66f22c..ab52084e9ca51 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -1187,7 +1187,7 @@ def from_records(cls, data, index=None, exclude=None, columns=None, return cls(mgr) - def to_records(self, index=True, convert_datetime64=False): + def to_records(self, index=True, convert_datetime64=None): """ Convert DataFrame to record array. Index will be put in the 'index' field of the record array if requested @@ -1196,7 +1196,7 @@ def to_records(self, index=True, convert_datetime64=False): ---------- index : boolean, default True Include index in resulting record array, stored in 'index' field - convert_datetime64 : boolean, default False + convert_datetime64 : boolean, optional .. deprecated:: 0.23.0 Whether to convert the index to datetime.datetime if it is a @@ -1207,7 +1207,7 @@ def to_records(self, index=True, convert_datetime64=False): y : recarray """ - if convert_datetime64: + if convert_datetime64 is not None: warnings.warn("The 'convert_datetime64' parameter is " "deprecated and will be removed in a future " "version", diff --git a/pandas/tests/frame/test_convert_to.py b/pandas/tests/frame/test_convert_to.py index f380a7ed606a2..0819e8c64c1f9 100644 --- a/pandas/tests/frame/test_convert_to.py +++ b/pandas/tests/frame/test_convert_to.py @@ -83,8 +83,9 @@ def test_to_records_dt64(self): result = df.to_records(convert_datetime64=True)['index'][0] assert expected == result - rs = df.to_records(convert_datetime64=False) - assert rs['index'][0] == df.index.values[0] + with tm.assert_produces_warning(FutureWarning): + rs = df.to_records(convert_datetime64=False) + assert rs['index'][0] == df.index.values[0] def test_to_records_with_multindex(self): # GH3189