Skip to content

DEPR: deprecating series asof GH10343 #10345

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
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
1 change: 0 additions & 1 deletion doc/source/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,6 @@ Time series-related
:toctree: generated/

Series.asfreq
Series.asof
Series.shift
Series.first_valid_index
Series.last_valid_index
Expand Down
5 changes: 5 additions & 0 deletions doc/source/whatsnew/v0.17.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,11 @@ Deprecations

- ``Categorical.name`` was deprecated to make ``Categorical`` more ``numpy.ndarray`` like. Use ``Series(cat, name="whatever")`` instead (:issue:`10482`).

- :meth:`Series.asof` is deprecated. Please use :meth:`Series.reindex(where, method='ffill')`
instead. This method does not drop missing values in the original series.

So `Series.asof(where)` is equivalent to `Series.dropna().reindex(where, method='ffill')`.

.. _whatsnew_0170.prior_deprecations:

Removal of prior version deprecations/changes
Expand Down
12 changes: 12 additions & 0 deletions pandas/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -2452,6 +2452,11 @@ def last_valid_index(self):

def asof(self, where):
"""
DEPRECATED. Please use :meth:`Series.reindex` instead.
So a `Series.asof(where)` can be replaced by
`Series.dropna().reindex(where, method='ffill')`.
Return last good (non-NaN) value in TimeSeries if value is NaN for
requested date.
Expand All @@ -2468,7 +2473,14 @@ def asof(self, where):
Returns
-------
value or NaN
See Also
--------
pandas.Series.reindex
"""
warnings.warn("`Series.asof` is deprecated, use "
"`Series.reindex` instead.", FutureWarning)
if isinstance(where, compat.string_types):
where = datetools.to_datetime(where)

Expand Down