Skip to content

Deprecated pandas.lib redirect messages #15936

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
jorisvandenbossche opened this issue Apr 7, 2017 · 7 comments
Closed

Deprecated pandas.lib redirect messages #15936

jorisvandenbossche opened this issue Apr 7, 2017 · 7 comments
Labels
Deprecate Functionality to remove in pandas
Milestone

Comments

@jorisvandenbossche
Copy link
Member

Currently, you get the following message when you try to access one of the pandas.lib functions:

In [1]: pd.lib.Timedelta
/home/joris/miniconda3/envs/dev/bin/ipython:1: FutureWarning: pandas.lib.Timedelta is deprecated. 
Please use pandas._libs.lib.Timedelta instead.
  #!/home/joris/miniconda3/envs/dev/bin/python
Out[1]: pandas._libs.tslib.Timedelta

In [1]: pd.lib.is_bool
/home/joris/miniconda3/envs/dev/bin/ipython:1: FutureWarning: pandas.lib.is_bool is deprecated. 
Please use pandas._libs.lib.is_bool instead.
  #!/home/joris/miniconda3/envs/dev/bin/python
Out[1]: <function pandas._libs.lib.is_bool>

(apart from infer_dtypes, for which there is already another redirect).

We shouldn't recommend to use pandas._lib.lib.
For some there is a public alternative (like Timestamp, Timedelta), others are probably just private and shouldn't have an alternative.

We could list all of them as removals and moved in lib = _DeprecatedModule(..), but that will be a long list. Or we could just don't provide an alternative import path by default, and only include some specific ones for which there is an alternative.

@jorisvandenbossche jorisvandenbossche added this to the 0.20.0 milestone Apr 7, 2017
@jreback jreback added the Deprecate Functionality to remove in pandas label Apr 7, 2017
@jreback
Copy link
Contributor

jreback commented Apr 7, 2017

xref #15909

is this issue about is_* that are directly imported from pandas.lib?

@jorisvandenbossche
Copy link
Member Author

is this issue about is_* that are directly imported from pandas.lib?

It is about all functions that are imported in pandas.lib. Currently that simply does from pandas._libs.lib import *.
So all functions available in _libs.lib are also accessible from pandas.lib, which is not necessarily bad (for backward compat), but they should not recommend to use the pandas._libs.lib version. So we should assess the pandas._libs.lib namespace and see which we want to expose publicly (and where) and which not.

Probably it is something like:

  • Timestamp, Timedelta, NaT -> refer to top-level
  • certain of the is_* methods -> refer to types module
  • all the rest = private -> do not refer to other import, just say it will be removed

@jreback
Copy link
Contributor

jreback commented Apr 9, 2017

hmm, I think then will just turn off the * imports. If any breakage that IS useful can just add to the public API (if we want). users should not use anything from these private libraries unless explicity exposed (that's the entire point of the API). most of these routines are already exposed in the API (e.g. the is_*).

I suppose putting deprecation warnings is ok here though.

@jorisvandenbossche
Copy link
Member Author

jorisvandenbossche commented Apr 9, 2017

Eg pd.lib.Timestamp is used (based on a quick SO search), so we should certainly put some things in pandas.lib for backwards compat. Easier to do * import IMO, but just changing the depr message.

@jreback
Copy link
Contributor

jreback commented Apr 9, 2017

yes aside from the ones you already have moved.

@jorisvandenbossche
Copy link
Member Author

jorisvandenbossche commented Apr 16, 2017

Dask is making use of lib.is_bool_array (https://github.com/dask/dask/blob/master/dask/dataframe/hashing.py#L8). Should we expose this in types ?

@jorisvandenbossche
Copy link
Member Author

Ah, since this for compat with older pandas versions (before has_pandas_object was introduced), probably not worth it, they could do the import inline after the 'else' clause.

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
Projects
None yet
Development

No branches or pull requests

2 participants