Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DEPR: remove stata deprecations from 2015 and 2017 #30176

Merged
merged 3 commits into from
Dec 10, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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