diff --git a/doc/source/whatsnew/v1.0.0.rst b/doc/source/whatsnew/v1.0.0.rst index 7ac1830af568c..3b87150f544cf 100644 --- a/doc/source/whatsnew/v1.0.0.rst +++ b/doc/source/whatsnew/v1.0.0.rst @@ -334,6 +334,7 @@ or ``matplotlib.Axes.plot``. See :ref:`plotting.formatters` for more. - Removed support for nexted renaming in :meth:`DataFrame.aggregate`, :meth:`Series.aggregate`, :meth:`DataFrameGroupBy.aggregate`, :meth:`SeriesGroupBy.aggregate`, :meth:`Rolling.aggregate` (:issue:`29608`) - Removed previously deprecated "order" argument from :func:`factorize` (:issue:`19751`) - Removed previously deprecated "v" argument from :meth:`FrozenNDarray.searchsorted`, use "value" instead (:issue:`22672`) +- :func:`read_stata` and :meth:`DataFrame.to_stata` no longer supports the "encoding" argument (:issue:`21400`) - Removed previously deprecated "raise_conflict" argument from :meth:`DataFrame.update`, use "errors" instead (:issue:`23585`) - Removed previously deprecated keyword "n" from :meth:`DatetimeIndex.shift`, :meth:`TimedeltaIndex.shift`, :meth:`PeriodIndex.shift`, use "periods" instead (:issue:`22458`) - diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 464067b9988bd..8b31b6d503eda 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -35,12 +35,7 @@ from pandas._libs import algos as libalgos, lib from pandas.compat.numpy import function as nv -from pandas.util._decorators import ( - Appender, - Substitution, - deprecate_kwarg, - rewrite_axis_style_signature, -) +from pandas.util._decorators import Appender, Substitution, rewrite_axis_style_signature from pandas.util._validators import ( validate_axis_style_args, validate_bool_kwarg, @@ -1853,13 +1848,11 @@ def _from_arrays(cls, arrays, columns, index, dtype=None): mgr = arrays_to_mgr(arrays, columns, index, columns, dtype=dtype) return cls(mgr) - @deprecate_kwarg(old_arg_name="encoding", new_arg_name=None) def to_stata( self, fname, convert_dates=None, write_index=True, - encoding="latin-1", byteorder=None, time_stamp=None, data_label=None, @@ -1889,8 +1882,6 @@ def to_stata( a datetime column has timezone information. write_index : bool Write the index to Stata dataset. - encoding : str - Default is latin-1. Unicode is not supported. byteorder : str Can be ">", "<", "little", or "big". default is `sys.byteorder`. time_stamp : datetime diff --git a/pandas/io/stata.py b/pandas/io/stata.py index 24539057a5db9..567eeb7f5cdc8 100644 --- a/pandas/io/stata.py +++ b/pandas/io/stata.py @@ -58,10 +58,6 @@ convert_categoricals : bool, default True Read value labels and convert columns to Categorical/Factor variables.""" -_encoding_params = """\ -encoding : str, None or encoding - Encoding used to parse the files. None defaults to latin-1.""" - _statafile_processing_params2 = """\ index_col : str, optional Column to set as index. @@ -108,7 +104,6 @@ %s %s %s -%s Returns ------- @@ -132,7 +127,6 @@ ... do_something(chunk) """ % ( _statafile_processing_params1, - _encoding_params, _statafile_processing_params2, _chunksize_params, _iterator_params, @@ -189,23 +183,19 @@ %s %s %s -%s """ % ( _statafile_processing_params1, _statafile_processing_params2, - _encoding_params, _chunksize_params, ) @Appender(_read_stata_doc) -@deprecate_kwarg(old_arg_name="encoding", new_arg_name=None) @deprecate_kwarg(old_arg_name="index", new_arg_name="index_col") def read_stata( filepath_or_buffer, convert_dates=True, convert_categoricals=True, - encoding=None, index_col=None, convert_missing=False, preserve_dtypes=True, @@ -1044,7 +1034,6 @@ def __init__(self): class StataReader(StataParser, BaseIterator): __doc__ = _stata_reader_doc - @deprecate_kwarg(old_arg_name="encoding", new_arg_name=None) @deprecate_kwarg(old_arg_name="index", new_arg_name="index_col") def __init__( self, @@ -1056,7 +1045,6 @@ def __init__( preserve_dtypes=True, columns=None, order_categoricals=True, - encoding=None, chunksize=None, ): super().__init__() @@ -2134,14 +2122,12 @@ class StataWriter(StataParser): _max_string_length = 244 - @deprecate_kwarg(old_arg_name="encoding", new_arg_name=None) def __init__( self, fname, data, convert_dates=None, write_index=True, - encoding="latin-1", byteorder=None, time_stamp=None, data_label=None, @@ -2859,8 +2845,6 @@ class StataWriter117(StataWriter): timezone information write_index : bool Write the index to Stata dataset. - encoding : str - Default is latin-1. Only latin-1 and ascii are supported. byteorder : str Can be ">", "<", "little", or "big". default is `sys.byteorder` time_stamp : datetime @@ -2912,14 +2896,12 @@ class StataWriter117(StataWriter): _max_string_length = 2045 - @deprecate_kwarg(old_arg_name="encoding", new_arg_name=None) def __init__( self, fname, data, convert_dates=None, write_index=True, - encoding="latin-1", byteorder=None, time_stamp=None, data_label=None, diff --git a/pandas/tests/io/test_stata.py b/pandas/tests/io/test_stata.py index 7fa3b968278d9..2cc80a6e5565d 100644 --- a/pandas/tests/io/test_stata.py +++ b/pandas/tests/io/test_stata.py @@ -383,8 +383,7 @@ def test_encoding(self, version): # GH 4626, proper encoding handling raw = read_stata(self.dta_encoding) - with tm.assert_produces_warning(FutureWarning): - encoded = read_stata(self.dta_encoding, encoding="latin-1") + encoded = read_stata(self.dta_encoding) result = encoded.kreis1849[0] expected = raw.kreis1849[0] @@ -392,10 +391,7 @@ def test_encoding(self, version): assert isinstance(result, str) with tm.ensure_clean() as path: - with tm.assert_produces_warning(FutureWarning): - encoded.to_stata( - path, write_index=False, version=version, encoding="latin-1" - ) + encoded.to_stata(path, write_index=False, version=version) reread_encoded = read_stata(path) tm.assert_frame_equal(encoded, reread_encoded)