Skip to content

Commit 1d32264

Browse files
datapythonistajreback
authored andcommitted
DOC: Using deprecated sphinx directive instead of non-standard messages in docstrings (#18928) (#18934)
1 parent 5bd0836 commit 1d32264

19 files changed

+204
-100
lines changed

ci/lint.sh

+4
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,10 @@ if [ "$LINT" ]; then
117117
fi
118118
done
119119
echo "Check for incorrect sphinx directives DONE"
120+
121+
echo "Check for deprecated messages without sphinx directive"
122+
grep -R --include="*.py" --include="*.pyx" -E "(DEPRECATED|DEPRECATE|Deprecated)(:|,|\.)" pandas
123+
echo "Check for deprecated messages without sphinx directive DONE"
120124
else
121125
echo "NOT Linting"
122126
fi

doc/source/contributing.rst

+24-1
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,30 @@ Backwards Compatibility
547547
Please try to maintain backward compatibility. *pandas* has lots of users with lots of
548548
existing code, so don't break it if at all possible. If you think breakage is required,
549549
clearly state why as part of the pull request. Also, be careful when changing method
550-
signatures and add deprecation warnings where needed.
550+
signatures and add deprecation warnings where needed. Also, add the deprecated sphinx
551+
directive to the deprecated functions or methods.
552+
553+
If a function with the same arguments as the one being deprecated exist, you can use
554+
the ``pandas.util._decorators.deprecate``:
555+
556+
.. code-block:: python
557+
558+
from pandas.util._decorators import deprecate
559+
560+
deprecate('old_func', 'new_func', '0.21.0')
561+
562+
Otherwise, you need to do it manually:
563+
564+
.. code-block:: python
565+
566+
def old_func():
567+
"""Summary of the function.
568+
569+
.. deprecated:: 0.21.0
570+
Use new_func instead.
571+
"""
572+
warnings.warn('Use new_func instead.', FutureWarning, stacklevel=2)
573+
new_func()
551574
552575
.. _contributing.ci:
553576

pandas/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
plot_params = pandas.plotting._style._Options(deprecated=True)
5252
# do not import deprecate to top namespace
5353
scatter_matrix = pandas.util._decorators.deprecate(
54-
'pandas.scatter_matrix', pandas.plotting.scatter_matrix,
54+
'pandas.scatter_matrix', pandas.plotting.scatter_matrix, '0.20.0',
5555
'pandas.plotting.scatter_matrix')
5656

5757
from pandas.util._print_versions import show_versions

pandas/_libs/tslibs/timestamps.pyx

-3
Original file line numberDiff line numberDiff line change
@@ -389,9 +389,6 @@ class Timestamp(_Timestamp):
389389
Unit used for conversion if ts_input is of type int or float. The
390390
valid values are 'D', 'h', 'm', 's', 'ms', 'us', and 'ns'. For
391391
example, 's' means seconds and 'ms' means milliseconds.
392-
offset : str, DateOffset
393-
Deprecated, use freq
394-
395392
year, month, day : int
396393
.. versionadded:: 0.19.0
397394
hour, minute, second, microsecond : int, optional, default 0

pandas/computation/expressions.py

+4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33

44
def set_use_numexpr(v=True):
5+
"""
6+
.. deprecated:: 0.20.0
7+
Use ``pandas.set_option('compute.use_numexpr', v)`` instead.
8+
"""
59
warnings.warn("pandas.computation.expressions.set_use_numexpr is "
610
"deprecated and will be removed in a future version.\n"
711
"you can toggle usage of numexpr via "

pandas/core/categorical.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,8 @@ def _get_labels(self):
594594
"""
595595
Get the category labels (deprecated).
596596
597-
Deprecated, use .codes!
597+
.. deprecated:: 0.15.0
598+
Use `.codes()` instead.
598599
"""
599600
warn("'labels' is deprecated. Use 'codes' instead", FutureWarning,
600601
stacklevel=2)

pandas/core/datetools.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
"""A collection of random tools for dealing with dates in Python"""
1+
"""A collection of random tools for dealing with dates in Python.
2+
3+
.. deprecated:: 0.19.0
4+
Use pandas.tseries module instead.
5+
"""
26

37
# flake8: noqa
48

pandas/core/dtypes/common.py

+5-7
Original file line numberDiff line numberDiff line change
@@ -758,10 +758,9 @@ def is_dtype_union_equal(source, target):
758758

759759

760760
def is_any_int_dtype(arr_or_dtype):
761-
"""
762-
DEPRECATED: This function will be removed in a future version.
761+
"""Check whether the provided array or dtype is of an integer dtype.
763762
764-
Check whether the provided array or dtype is of an integer dtype.
763+
.. deprecated:: 0.20.0
765764
766765
In this function, timedelta64 instances are also considered "any-integer"
767766
type objects and will return True.
@@ -1557,12 +1556,11 @@ def is_float_dtype(arr_or_dtype):
15571556

15581557

15591558
def is_floating_dtype(arr_or_dtype):
1560-
"""
1561-
DEPRECATED: This function will be removed in a future version.
1562-
1563-
Check whether the provided array or dtype is an instance of
1559+
"""Check whether the provided array or dtype is an instance of
15641560
numpy's float dtype.
15651561
1562+
.. deprecated:: 0.20.0
1563+
15661564
Unlike, `is_float_dtype`, this check is a lot stricter, as it requires
15671565
`isinstance` of `np.floating` and not `issubclass`.
15681566
"""

pandas/core/frame.py

+14-16
Original file line numberDiff line numberDiff line change
@@ -1326,9 +1326,10 @@ def _from_arrays(cls, arrays, columns, index, dtype=None):
13261326
def from_csv(cls, path, header=0, sep=',', index_col=0, parse_dates=True,
13271327
encoding=None, tupleize_cols=None,
13281328
infer_datetime_format=False):
1329-
"""
1330-
Read CSV file (DEPRECATED, please use :func:`pandas.read_csv`
1331-
instead).
1329+
"""Read CSV file.
1330+
1331+
.. deprecated:: 0.21.0
1332+
Use :func:`pandas.read_csv` instead.
13321333
13331334
It is preferable to use the more powerful :func:`pandas.read_csv`
13341335
for most general purposes, but ``from_csv`` makes for an easy
@@ -1979,12 +1980,10 @@ def _unpickle_matrix_compat(self, state): # pragma: no cover
19791980
# Getting and setting elements
19801981

19811982
def get_value(self, index, col, takeable=False):
1982-
"""
1983-
Quickly retrieve single value at passed column and index
1983+
"""Quickly retrieve single value at passed column and index
19841984
19851985
.. deprecated:: 0.21.0
1986-
1987-
Please use .at[] or .iat[] accessors.
1986+
Use .at[] or .iat[] accessors instead.
19881987
19891988
Parameters
19901989
----------
@@ -2024,12 +2023,10 @@ def _get_value(self, index, col, takeable=False):
20242023
_get_value.__doc__ = get_value.__doc__
20252024

20262025
def set_value(self, index, col, value, takeable=False):
2027-
"""
2028-
Put single value at passed column and index
2026+
"""Put single value at passed column and index
20292027
20302028
.. deprecated:: 0.21.0
2031-
2032-
Please use .at[] or .iat[] accessors.
2029+
Use .at[] or .iat[] accessors instead.
20332030
20342031
Parameters
20352032
----------
@@ -3737,12 +3734,13 @@ def sort_index(self, axis=0, level=None, ascending=True, inplace=False,
37373734

37383735
def sortlevel(self, level=0, axis=0, ascending=True, inplace=False,
37393736
sort_remaining=True):
3740-
"""
3741-
DEPRECATED: use :meth:`DataFrame.sort_index`
3742-
3743-
Sort multilevel index by chosen axis and primary level. Data will be
3737+
"""Sort multilevel index by chosen axis and primary level. Data will be
37443738
lexicographically sorted by the chosen level followed by the other
3745-
levels (in order)
3739+
levels (in order).
3740+
3741+
.. deprecated:: 0.20.0
3742+
Use :meth:`DataFrame.sort_index`
3743+
37463744
37473745
Parameters
37483746
----------

pandas/core/generic.py

+14-13
Original file line numberDiff line numberDiff line change
@@ -2718,10 +2718,10 @@ def xs(self, key, axis=0, level=None, drop_level=True):
27182718
_xs = xs
27192719

27202720
def select(self, crit, axis=0):
2721-
"""
2722-
Return data corresponding to axis labels matching criteria
2721+
"""Return data corresponding to axis labels matching criteria
27232722
2724-
DEPRECATED: use df.loc[df.index.map(crit)] to select via labels
2723+
.. deprecated:: 0.21.0
2724+
Use df.loc[df.index.map(crit)] to select via labels
27252725
27262726
Parameters
27272727
----------
@@ -4108,8 +4108,11 @@ def _consolidate(self, inplace=False):
41084108
return self._constructor(cons_data).__finalize__(self)
41094109

41104110
def consolidate(self, inplace=False):
4111-
"""
4112-
DEPRECATED: consolidate will be an internal implementation only.
4111+
"""Compute NDFrame with "consolidated" internals (data of each dtype
4112+
grouped together in a single ndarray).
4113+
4114+
.. deprecated:: 0.20.0
4115+
Consolidate will be an internal implementation only.
41134116
"""
41144117
# 15483
41154118
warnings.warn("consolidate is deprecated and will be removed in a "
@@ -4160,11 +4163,10 @@ def _get_bool_data(self):
41604163
# Internal Interface Methods
41614164

41624165
def as_matrix(self, columns=None):
4163-
"""
4164-
DEPRECATED: as_matrix will be removed in a future version.
4165-
Use :meth:`DataFrame.values` instead.
4166+
"""Convert the frame to its Numpy-array representation.
41664167
4167-
Convert the frame to its Numpy-array representation.
4168+
.. deprecated:: 0.23.0
4169+
Use :meth:`DataFrame.values` instead.
41684170
41694171
Parameters
41704172
----------
@@ -4479,12 +4481,11 @@ def _convert(self, datetime=False, numeric=False, timedelta=False,
44794481
timedelta=timedelta, coerce=coerce,
44804482
copy=copy)).__finalize__(self)
44814483

4482-
# TODO: Remove in 0.18 or 2017, which ever is sooner
44834484
def convert_objects(self, convert_dates=True, convert_numeric=False,
44844485
convert_timedeltas=True, copy=True):
4485-
"""
4486-
Deprecated.
4487-
Attempt to infer better dtype for object columns
4486+
"""Attempt to infer better dtype for object columns.
4487+
4488+
.. deprecated:: 0.21.0
44884489
44894490
Parameters
44904491
----------

pandas/core/indexes/datetimelike.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -441,9 +441,10 @@ def _isnan(self):
441441

442442
@property
443443
def asobject(self):
444-
"""DEPRECATED: Use ``astype(object)`` instead.
444+
"""Return object Index which contains boxed values.
445445
446-
return object Index which contains boxed values
446+
.. deprecated:: 0.23.0
447+
Use ``astype(object)`` instead.
447448
448449
*this is an internal non-public method*
449450
"""

pandas/core/panel.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -477,8 +477,7 @@ def as_matrix(self):
477477
# Getting and setting elements
478478

479479
def get_value(self, *args, **kwargs):
480-
"""
481-
Quickly retrieve single value at (item, major, minor) location
480+
"""Quickly retrieve single value at (item, major, minor) location
482481
483482
.. deprecated:: 0.21.0
484483
@@ -525,8 +524,7 @@ def _get_value(self, *args, **kwargs):
525524
_get_value.__doc__ = get_value.__doc__
526525

527526
def set_value(self, *args, **kwargs):
528-
"""
529-
Quickly set single value at (item, major, minor) location
527+
"""Quickly set single value at (item, major, minor) location
530528
531529
.. deprecated:: 0.21.0
532530

0 commit comments

Comments
 (0)