From 94777aa0666f5e8b28e8901f8351cb8f4fab2d42 Mon Sep 17 00:00:00 2001 From: Bernard Willers Date: Fri, 12 Jun 2015 23:03:07 -0400 Subject: [PATCH] DEPR: deprecating series asof GH10343 --- doc/source/api.rst | 1 - doc/source/whatsnew/v0.17.0.txt | 5 +++++ pandas/core/series.py | 12 ++++++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/doc/source/api.rst b/doc/source/api.rst index 1cbe55ddbacb6..620cef3f7fc74 100644 --- a/doc/source/api.rst +++ b/doc/source/api.rst @@ -449,7 +449,6 @@ Time series-related :toctree: generated/ Series.asfreq - Series.asof Series.shift Series.first_valid_index Series.last_valid_index diff --git a/doc/source/whatsnew/v0.17.0.txt b/doc/source/whatsnew/v0.17.0.txt index 921decdd03ca9..2cd096261a931 100644 --- a/doc/source/whatsnew/v0.17.0.txt +++ b/doc/source/whatsnew/v0.17.0.txt @@ -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 diff --git a/pandas/core/series.py b/pandas/core/series.py index 6586fa10935e6..c8ae78926b28b 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -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. @@ -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)