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

Conversation

bwillers
Copy link
Contributor

closes #10343 and discussion on #10266 - deprecating Series.asof(where) in favour of Series.reindex(where, method='ffill').

@jreback
Copy link
Contributor

jreback commented Jun 14, 2015

this is ok, but I think this could use a small doc-section in missing.rst in the fillna subsection.

also will have to add a reference in the deprecate issue #6581 (will do this upon merging)

@jreback jreback added Docs Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate Deprecate Functionality to remove in pandas labels Jun 14, 2015
@jreback jreback added this to the 0.17.0 milestone Jun 14, 2015
@bwillers
Copy link
Contributor Author

@jreback I'd be happy to add it, but I'm not entirely sure what you're looking for here. I had a look through the missing_data.rst and there's no mention of asof to correct/update. Since it is a reindexing method, it's not clear how it should documented in the missing data section.

@jreback
Copy link
Contributor

jreback commented Aug 5, 2015

@bwillers can you rebase?

@bwillers
Copy link
Contributor Author

bwillers commented Aug 6, 2015

@jreback rebased and green

DEPRECATED. Please use :meth:`Series.reindex` instead.

So a `Series.asof(where)` can be replaced by
`Series.dropna().reindex(where, method='ffil')`.
Copy link
Contributor

Choose a reason for hiding this comment

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

ffill

@jreback
Copy link
Contributor

jreback commented Aug 6, 2015

Can you put a mini-doc section right after here: http://pandas.pydata.org/pandas-docs/stable/timeseries.html#filling-forward-backward

showing an asof usecase (using the reindexing and fill method). Also a pointer in the whatsnew to this new doc section would be great. thxs.

@max-sixty
Copy link
Contributor

If everyone thinks this is a good idea to deprecate, then so be it. I should say that we use this a lot, and find it a really convenient method. There are lots of use cases where you want to ask "what was the most recent valid value". And asof is much simpler than Series.reindex(where, method='ffill'), particularly when reading code.

Am I missing something? Or are we just particular in our use case?

@bwillers
Copy link
Contributor Author

bwillers commented Aug 7, 2015

@MaximilianR Well, the motivation here is mainly based on asof being a re-implementation of functionality that already exists in the better tested and more widely applicable reindex. I absolutely agree that the basic operation of wanting to know the most recent value is a common one, and that s.dropna().reindex(where, method='ffill') is unfortunately a lot more verbose than s.asof(where).

That said, reindex has the advantage of working for a NDFrame or DataFrame, and working with a MultiIndex, none of which are supported by asof.

The question becomes if the convenience of the shorter form for the specialized use case is worth the code bloat from multiple implementations of the same thing. I'm not personally convinced that it does, but that's definitely something worth discussing.

@max-sixty
Copy link
Contributor

@bwillers completely agree with that synthesis - i.e. the big question being how useful a method needs to be in order to compensate for the additional clutter.

One point to consider for the specific case is how obvious that translation is for the average user. I'd have thought 'not very obvious', but I don't have a great handle on what the average current / future user looks like.

If we do keep it, having it as a simple wrapper of the translation seems wise.

Over to the maintainers on the broader question...

@jorisvandenbossche
Copy link
Member

As a reference, asof is used in Python for Data Analysis

@jorisvandenbossche
Copy link
Member

Note: I never used asof myself, so difficult to assess.
But, if asof is used and is useful, I think we should reconsider the deprecation. I agree that the equivalent of s.dropna().reindex(where, method='ffill') is not that straightforward, and easy to come up with.

We either deprecate it, or we keep it and see this as an opportunitiy to:

  • reimplement it using the existing and better tested reindexing machinery
  • in this way, make the function more general (not restricted to timeseries)
  • in the docstring, make it clear that this is a shortcut for a reindexing operation, and if you want more options (other filling etc) or use it for a dataframe you should use that. In this way, the function can also be somewhat educational to explain what reindexing does
  • also explain this in the tutorial docs

And maybe it would be useful to have some kind of skipna kwarg in reindex?

@bwillers
Copy link
Contributor Author

@jorisvandenbossche That's not a bad idea - effectively 'replumb' the asof internals into reindex, but leave the compact and fairly intuitive api the same.

@jreback
Copy link
Contributor

jreback commented Aug 11, 2015

@bwillers ok!

@jreback
Copy link
Contributor

jreback commented Aug 13, 2015

ok, I revised the original issue. Let's try to reimplement this using .reindex internally, add tests, and leave the API.

@jreback jreback closed this Aug 13, 2015
@jreback
Copy link
Contributor

jreback commented Aug 13, 2015

@bwillers you can repurpose this PR or open a new one up to u

@bwillers
Copy link
Contributor Author

@jreback sounds good, running around like a headless chicken this week but hope to get this done next.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Deprecate Functionality to remove in pandas Docs Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CLN: Series.asof
4 participants