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

DOC: Update Sphinx Deprecated Directive #16512

Merged
merged 9 commits into from
Jun 27, 2017
17 changes: 11 additions & 6 deletions doc/source/io.rst
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,9 @@ usecols : array-like or callable, default ``None``

Using this parameter results in much faster parsing time and lower memory usage.
as_recarray : boolean, default ``False``
DEPRECATED: this argument will be removed in a future version. Please call
``pd.read_csv(...).to_records()`` instead.
.. deprecated:: 0.18.2
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When using the deprecated directive, you will need to add blank lines around it

This argument will be removed in a future version. Please call
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would eliminate things like: This argument will be removed in a future version. (look for occurences in the changes you made)

as the deprecated tag already has this (I think)

``pd.read_csv(...).to_records()`` instead.

Return a NumPy recarray instead of a DataFrame after parsing the data. If
set to ``True``, this option takes precedence over the ``squeeze`` parameter.
Expand Down Expand Up @@ -191,7 +192,8 @@ skiprows : list-like or integer, default ``None``
skipfooter : int, default ``0``
Number of lines at bottom of file to skip (unsupported with engine='c').
skip_footer : int, default ``0``
DEPRECATED: use the ``skipfooter`` parameter instead, as they are identical
.. deprecated:: 0.19.0
Use the ``skipfooter`` parameter instead, as they are identical
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

e.g. this like this

nrows : int, default ``None``
Number of rows of file to read. Useful for reading pieces of large files.
low_memory : boolean, default ``True``
Expand All @@ -202,16 +204,19 @@ low_memory : boolean, default ``True``
use the ``chunksize`` or ``iterator`` parameter to return the data in chunks.
(Only valid with C parser)
buffer_lines : int, default None
DEPRECATED: this argument will be removed in a future version because its
value is not respected by the parser
.. deprecated:: 0.18.2
This argument will be removed in a future version because its
value is not respected by the parser
compact_ints : boolean, default False
.. deprecated:: 0.18.2
DEPRECATED: this argument will be removed in a future version

If ``compact_ints`` is ``True``, then for any column that is of integer dtype, the
parser will attempt to cast it as the smallest integer ``dtype`` possible, either
signed or unsigned depending on the specification from the ``use_unsigned`` parameter.
use_unsigned : boolean, default False
DEPRECATED: this argument will be removed in a future version
.. deprecated:: 0.18.2
This argument will be removed in a future version

If integer columns are being compacted (i.e. ``compact_ints=True``), specify whether
the column should be compacted to the smallest signed or unsigned integer dtype.
Expand Down
4 changes: 3 additions & 1 deletion doc/sphinxext/numpydoc/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ The following options can be set in conf.py:
methods and attributes. If a table of contents is made, Sphinx expects
each entry to have a separate page.

- numpydoc_edit_link: bool (DEPRECATED -- edit your HTML template instead)
- numpydoc_edit_link: bool
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please leave this one as is (numpydoc's source is just included in pandas, we should adapt it only minimally)

.. deprecated::
Edit your HTML template instead

Whether to insert an edit link after docstrings.
3 changes: 2 additions & 1 deletion pandas/_libs/tslib.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1148,7 +1148,8 @@ cdef class _Timestamp(datetime):

cpdef datetime to_datetime(_Timestamp self):
"""
DEPRECATED: use :meth:`to_pydatetime` instead.
.. deprecated:: 0.19.0
Use :meth:`to_pydatetime` instead.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you leave this one as is? The thing is that the first sentence of the docstring gets added to the API overview. So the actual "DEPRECATED .. " is then more useful as the directive code (although I am actually not sure what sphinx would put in the api summary table)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems sphinx only parses the first line to the summary table as expected. The changes have been reverted to avoid losing information in the API summary table.

screenshot from 2017-06-15 09-41-54


Convert a Timestamp object to a native Python datetime object.
"""
Expand Down
21 changes: 12 additions & 9 deletions pandas/core/categorical.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,8 +391,8 @@ def itemsize(self):

def reshape(self, new_shape, *args, **kwargs):
"""
DEPRECATED: calling this method will raise an error in a
future release.
.. deprecated:: 0.19.0
Calling this method will raise an error in a future release.

An ndarray-compatible method that returns `self` because
`Categorical` instances cannot actually be reshaped.
Expand Down Expand Up @@ -423,7 +423,8 @@ def base(self):
@classmethod
def from_array(cls, data, **kwargs):
"""
DEPRECATED: Use ``Categorical`` instead.
.. deprecated::
Use ``Categorical`` instead.

Make a Categorical type from a single array-like object.

Expand Down Expand Up @@ -1442,8 +1443,9 @@ def _values_for_rank(self):

def order(self, inplace=False, ascending=True, na_position='last'):
"""
DEPRECATED: use :meth:`Categorical.sort_values`. That function
is entirely equivalent to this one.
.. deprecated:: 0.18.1
Use :meth:`Categorical.sort_values`. That function
is entirely equivalent to this one.

See Also
--------
Expand All @@ -1456,10 +1458,11 @@ def order(self, inplace=False, ascending=True, na_position='last'):

def sort(self, inplace=True, ascending=True, na_position='last', **kwargs):
"""
DEPRECATED: use :meth:`Categorical.sort_values`. That function
is just like this one, except that a new Categorical is returned
by default, so make sure to pass in 'inplace=True' to get
inplace sorting.
.. deprecated:: 0.18.1
Use :meth:`Categorical.sort_values`. That function
is just like this one, except that a new Categorical is returned
by default, so make sure to pass in 'inplace=True' to get
inplace sorting.

See Also
--------
Expand Down
7 changes: 4 additions & 3 deletions pandas/core/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,8 @@ def in_qtconsole():
"""
check if we're inside an IPython qtconsole

DEPRECATED: This is no longer needed, or working, in IPython 3 and above.
.. deprecated:: 0.14.1
This is no longer needed, or working, in IPython 3 and above.
"""
try:
ip = get_ipython() # noqa
Expand All @@ -566,8 +567,8 @@ def in_ipnb():
"""
check if we're inside an IPython Notebook

DEPRECATED: This is no longer used in pandas, and won't work in IPython 3
and above.
.. deprecated:: 0.14.1
This is no longer used in pandas, and won't work in IPython 3 and above.
"""
try:
ip = get_ipython() # noqa
Expand Down
3 changes: 2 additions & 1 deletion pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -3477,7 +3477,8 @@ def sort_index(self, axis=0, level=None, ascending=True, inplace=False,
def sortlevel(self, level=0, axis=0, ascending=True, inplace=False,
sort_remaining=True):
"""
DEPRECATED: use :meth:`DataFrame.sort_index`
.. deprecated:: 0.20.0
Use :meth:`DataFrame.sort_index`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as above for this one, and some others below as well


Sort multilevel index by chosen axis and primary level. Data will be
lexicographically sorted by the chosen level followed by the other
Expand Down
21 changes: 13 additions & 8 deletions pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -1322,9 +1322,10 @@ def to_sql(self, name, con, flavor=None, schema=None, if_exists='fail',
Using SQLAlchemy makes it possible to use any DB supported by that
library. If a DBAPI2 object, only sqlite3 is supported.
flavor : 'sqlite', default None
DEPRECATED: this parameter will be removed in a future version,
as 'sqlite' is the only supported option if SQLAlchemy is not
installed.
.. deprecated:: 0.19.0
This parameter will be removed in a future version,
as 'sqlite' is the only supported option if SQLAlchemy is not
installed.
schema : string, default None
Specify the schema (if database flavor supports this). If None, use
default schema.
Expand Down Expand Up @@ -3162,7 +3163,8 @@ def _consolidate(self, inplace=False):

def consolidate(self, inplace=False):
"""
DEPRECATED: consolidate will be an internal implementation only.
.. deprecated:: 0.20.0
Consolidate will be an internal implementation only.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment here as previous. By putting this deprecated directive on the first line, it gets less informative in a api summary table

"""
# 15483
warnings.warn("consolidate is deprecated and will be removed in a "
Expand Down Expand Up @@ -3373,7 +3375,9 @@ def astype(self, dtype, copy=True, errors='raise', **kwargs):

.. versionadded:: 0.20.0

raise_on_error : DEPRECATED use ``errors`` instead
raise_on_error : raise on invalid input
.. deprecated:: 0.20.0
Use ``errors`` instead
kwargs : keyword arguments to pass on to the constructor

Returns
Expand Down Expand Up @@ -3476,7 +3480,7 @@ def _convert(self, datetime=False, numeric=False, timedelta=False,
def convert_objects(self, convert_dates=True, convert_numeric=False,
convert_timedeltas=True, copy=True):
"""
Deprecated.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one should not be removed I think

.. deprecated:: 0.18.0

Attempt to infer better dtype for object columns

Expand Down Expand Up @@ -5684,8 +5688,9 @@ def tz_localize(self, tz, axis=0, level=None, copy=True,
- 'NaT' will return NaT where there are ambiguous times
- 'raise' will raise an AmbiguousTimeError if there are ambiguous
times
infer_dst : boolean, default False (DEPRECATED)
Attempt to infer fall dst-transition hours based on order
infer_dst : boolean, default False
.. deprecated:: 0.15.0
Attempt to infer fall dst-transition hours based on order

Returns
-------
Expand Down
3 changes: 2 additions & 1 deletion pandas/core/indexes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1008,7 +1008,8 @@ def _to_safe_for_reshape(self):

def to_datetime(self, dayfirst=False):
"""
DEPRECATED: use :meth:`pandas.to_datetime` instead.
.. deprecated:: 0.19.0
Use :meth:`pandas.to_datetime` instead.

For an Index containing strings or datetime.datetime objects, attempt
conversion to DatetimeIndex
Expand Down
10 changes: 6 additions & 4 deletions pandas/core/indexes/datetimes.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,9 @@ class DatetimeIndex(DatelikeOps, TimelikeOps, DatetimeIndexOpsMixin,
times)
- 'NaT' will return NaT where there are ambiguous times
- 'raise' will raise an AmbiguousTimeError if there are ambiguous times
infer_dst : boolean, default False (DEPRECATED)
Attempt to infer fall dst-transition hours based on order
infer_dst : boolean, default False
.. deprecated:: 0.15.0
Attempt to infer fall dst-transition hours based on order
name : object
Name to be stored in the index

Expand Down Expand Up @@ -1818,8 +1819,9 @@ def tz_localize(self, tz, ambiguous='raise', errors='raise'):

.. versionadded:: 0.19.0

infer_dst : boolean, default False (DEPRECATED)
Attempt to infer fall dst-transition hours based on order
infer_dst : boolean, default False
.. deprecated:: 0.15.0
Attempt to infer fall dst-transition hours based on order

Returns
-------
Expand Down
3 changes: 2 additions & 1 deletion pandas/core/indexes/period.py
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,8 @@ def asfreq(self, freq=None, how='E'):

def to_datetime(self, dayfirst=False):
"""
DEPRECATED: use :meth:`to_timestamp` instead.
.. deprecated:: 0.19.0
Use :meth:`to_timestamp` instead.

Cast to DatetimeIndex.
"""
Expand Down
9 changes: 5 additions & 4 deletions pandas/core/panel4d.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@
having 4 named dimensions. It is intended as a test bed for more
N-Dimensional named containers.

DEPRECATED. Panel4D is deprecated and will be removed in a future version.
The recommended way to represent these types of n-dimensional data are with
the `xarray package <http://xarray.pydata.org/en/stable/>`__.
Pandas provides a `.to_xarray()` method to automate this conversion.
.. deprecated:: 0.19.0
Panel4D is deprecated and will be removed in a future version.
The recommended way to represent these types of n-dimensional data
are with the `xarray package <http://xarray.pydata.org/en/stable/>`__.
Pandas provides a `.to_xarray()` method to automate this conversion.

Parameters
----------
Expand Down
9 changes: 5 additions & 4 deletions pandas/core/panelnd.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ def create_nd_panel_factory(klass_name, orders, slices, slicer, aliases=None,
stat_axis=2, info_axis=0, ns=None):
""" manufacture a n-d class:

DEPRECATED. Panelnd is deprecated and will be removed in a future version.
The recommended way to represent these types of n-dimensional data are with
the `xarray package <http://xarray.pydata.org/en/stable/>`__.
Pandas provides a `.to_xarray()` method to automate this conversion.
.. deprecated:: 0.19.0
Panelnd is deprecated and will be removed in a future version.
The recommended way to represent these types of n-dimensional data
are with the `xarray package <http://xarray.pydata.org/en/stable/>`__.
Pandas provides a `.to_xarray()` method to automate this conversion.

Parameters
----------
Expand Down
8 changes: 5 additions & 3 deletions pandas/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -850,8 +850,9 @@ def repeat(self, repeats, *args, **kwargs):

def reshape(self, *args, **kwargs):
"""
DEPRECATED: calling this method will raise an error in a
future release. Please call ``.values.reshape(...)`` instead.
.. deprecated:: 0.19.0
Calling this method will raise an error in a future release.
Please call ``.values.reshape(...)`` instead.

return an ndarray with the values shape
if the specified shape matches exactly the current shape, then
Expand Down Expand Up @@ -1940,7 +1941,8 @@ def nsmallest(self, n=5, keep='first'):

def sortlevel(self, level=0, ascending=True, sort_remaining=True):
"""
DEPRECATED: use :meth:`Series.sort_index`
.. deprecated:: 0.20.0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one I would leave as well

Use :meth:`Series.sort_index`

Sort Series with MultiIndex by chosen level. Data will be
lexicographically sorted by the chosen level followed by the other
Expand Down
5 changes: 3 additions & 2 deletions pandas/core/sparse/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,8 +391,9 @@ def to_dense(self, fill=None):
Parameters
----------
fill: float, default None
DEPRECATED: this argument will be removed in a future version
because it is not respected by this function.
.. deprecated:: 0.20.0
This argument will be removed in a future version
because it is not respected by this function.

Returns
-------
Expand Down
5 changes: 4 additions & 1 deletion pandas/core/strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,10 @@ def str_match(arr, pat, case=True, flags=0, na=np.nan, as_indexer=None):
flags : int, default 0 (no flags)
re module flags, e.g. re.IGNORECASE
na : default NaN, fill value for missing values.
as_indexer : DEPRECATED
as_indexer : False, by default, gives deprecated behavior better
achieved using str_extract. True return boolean indexer.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not fully correct. It is just ignored, so the explanation for True or False doesn't matter.

.. deprecated:: 0.20.0
Keyword is ignored

Returns
-------
Expand Down
Loading