Skip to content

Commit

Permalink
DEPR: remove stata deprecations from 2015 and 2017 (pandas-dev#30176)
Browse files Browse the repository at this point in the history
  • Loading branch information
jbrockmendel authored and proost committed Dec 19, 2019
1 parent cbba4c2 commit d1a5392
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 47 deletions.
1 change: 0 additions & 1 deletion doc/redirects.csv
Original file line number Diff line number Diff line change
Expand Up @@ -779,7 +779,6 @@ generated/pandas.io.formats.style.Styler.use,../reference/api/pandas.io.formats.
generated/pandas.io.formats.style.Styler.where,../reference/api/pandas.io.formats.style.Styler.where
generated/pandas.io.json.build_table_schema,../reference/api/pandas.io.json.build_table_schema
generated/pandas.io.json.json_normalize,../reference/api/pandas.io.json.json_normalize
generated/pandas.io.stata.StataReader.data,../reference/api/pandas.io.stata.StataReader.data
generated/pandas.io.stata.StataReader.data_label,../reference/api/pandas.io.stata.StataReader.data_label
generated/pandas.io.stata.StataReader.value_labels,../reference/api/pandas.io.stata.StataReader.value_labels
generated/pandas.io.stata.StataReader.variable_labels,../reference/api/pandas.io.stata.StataReader.variable_labels
Expand Down
1 change: 0 additions & 1 deletion doc/source/reference/io.rst
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ STATA
.. autosummary::
:toctree: api/

StataReader.data
StataReader.data_label
StataReader.value_labels
StataReader.variable_labels
Expand Down
2 changes: 2 additions & 0 deletions doc/source/whatsnew/v1.0.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,8 @@ or ``matplotlib.Axes.plot``. See :ref:`plotting.formatters` for more.

**Other removals**

- Removed the previously deprecated "index" keyword from :func:`read_stata`, :class:`StataReader`, and :meth:`StataReader.read`, use "index_col" instead (:issue:`17328`)
- Removed the previously deprecated :meth:`StataReader.data` method, use :meth:`StataReader.read` instead (:issue:`9493`)
- Removed the previously deprecated :func:`pandas.plotting._matplotlib.tsplot`, use :meth:`Series.plot` instead (:issue:`19980`)
- :func:`pandas.tseries.converter.register` has been moved to :func:`pandas.plotting.register_matplotlib_converters` (:issue:`18307`)
- :meth:`Series.plot` no longer accepts positional arguments, pass keyword arguments instead (:issue:`30003`)
Expand Down
36 changes: 1 addition & 35 deletions pandas/io/stata.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

from pandas._libs.lib import infer_dtype
from pandas._libs.writers import max_len_string_array
from pandas.util._decorators import Appender, deprecate_kwarg
from pandas.util._decorators import Appender

from pandas.core.dtypes.common import (
ensure_object,
Expand Down Expand Up @@ -132,25 +132,6 @@
_iterator_params,
)

_data_method_doc = """
Read observations from Stata file, converting them into a dataframe.
.. deprecated::
This is a legacy method. Use `read` in new code.
Parameters
----------
%s
%s
Returns
-------
DataFrame
""" % (
_statafile_processing_params1,
_statafile_processing_params2,
)

_read_method_doc = """\
Reads observations from Stata file, converting them into a dataframe
Expand Down Expand Up @@ -191,7 +172,6 @@


@Appender(_read_stata_doc)
@deprecate_kwarg(old_arg_name="index", new_arg_name="index_col")
def read_stata(
filepath_or_buffer,
convert_dates=True,
Expand Down Expand Up @@ -1033,7 +1013,6 @@ def __init__(self):
class StataReader(StataParser, BaseIterator):
__doc__ = _stata_reader_doc

@deprecate_kwarg(old_arg_name="index", new_arg_name="index_col")
def __init__(
self,
path_or_buf,
Expand Down Expand Up @@ -1525,18 +1504,6 @@ def _read_strls(self):
# Wrap v_o in a string to allow uint64 values as keys on 32bit OS
self.GSO[str(v_o)] = va

# legacy
@Appender(_data_method_doc)
def data(self, **kwargs):

warnings.warn("'data' is deprecated, use 'read' instead")

if self._data_read:
raise Exception("Data has already been read.")
self._data_read = True

return self.read(None, **kwargs)

def __next__(self):
return self.read(nrows=self._chunksize or 1)

Expand All @@ -1558,7 +1525,6 @@ def get_chunk(self, size=None):
return self.read(nrows=size)

@Appender(_read_method_doc)
@deprecate_kwarg(old_arg_name="index", new_arg_name="index_col")
def read(
self,
nrows=None,
Expand Down
10 changes: 0 additions & 10 deletions pandas/tests/io/test_stata.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,16 +120,6 @@ def test_read_empty_dta(self, version):
empty_ds2 = read_stata(path)
tm.assert_frame_equal(empty_ds, empty_ds2)

def test_data_method(self):
# Minimal testing of legacy data method
with StataReader(self.dta1_114) as rdr:
with tm.assert_produces_warning(UserWarning):
parsed_114_data = rdr.data()

with StataReader(self.dta1_114) as rdr:
parsed_114_read = rdr.read()
tm.assert_frame_equal(parsed_114_data, parsed_114_read)

@pytest.mark.parametrize("file", ["dta1_114", "dta1_117"])
def test_read_dta1(self, file):

Expand Down

0 comments on commit d1a5392

Please sign in to comment.