Skip to content
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

deprecation warning importing pandas (python2.7 only) #19944

Closed
dchudz opened this issue Mar 1, 2018 · 6 comments

Comments

Projects
None yet
6 participants
@dchudz
Copy link

commented Mar 1, 2018

Code Sample:

$mkvirtualenv pandas-deprecation-repro --python=python2.7
$workon pandas-deprecation-repro
$pip install pandas

$PYTHONWARNINGS=error::FutureWarning python -c "import pandas"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Users/davidchudzicki/.virtualenvs/pandas-deprecation-repro/lib/python2.7/site-packages/pandas/__init__.py", line 84, in <module>
    from ._version import get_versions
  File "/Users/davidchudzicki/.virtualenvs/pandas-deprecation-repro/lib/python2.7/site-packages/pandas/_version.py", line 9, in <module>
    import json
  File "/Users/davidchudzicki/.virtualenvs/pandas-deprecation-repro/lib/python2.7/site-packages/pandas/json.py", line 6, in <module>
    "pandas.io.json instead", FutureWarning, stacklevel=2)
FutureWarning: The pandas.json module is deprecated and will be removed in a future version. Please import from pandas.io.json instead

Problem description

I help with a package that wants to run our tests with PYTHONWARNINGS=error::FutureWarning, so that we can learn about changes in our dependencies and can avoid passing on deprecation warnings to our users. When we turn this on, import pandas gives us an error.

It looks like _version.py (autogenerated as part of your release process?) includes an import json that's interpreted (incorrectly) as referring to the old pandas.json.

$cat /Users/davidchudzicki/.virtualenvs/pandas-deprecation-repro/lib/python2.7/site-packages/pandas/_version.py

# This file was generated by 'versioneer.py' (0.15) from
# revision-control system data, or from the parent directory name of an
# unpacked source archive. Distribution tarballs contain a pre-generated copy
# of this file.

from warnings import catch_warnings
with catch_warnings(record=True):
    import json
import sys

version_json = '''
{
 "dirty": false,
 "error": null,
 "full-revisionid": "a00154dcfe5057cb3fd86653172e74b6893e337d",
 "version": "0.22.0"
}
'''  # END VERSION_JSON


def get_versions():
    return json.loads(version_json)

Output of pd.show_versions()

>>> import pandas as pd
>>> pd.show_versions()

INSTALLED VERSIONS
------------------
commit: None
python: 2.7.13.final.0
python-bits: 64
OS: Darwin
OS-release: 16.5.0
machine: x86_64
processor: i386
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: None.None

pandas: 0.22.0
pytest: None
pip: 9.0.1
setuptools: 38.5.1
Cython: None
numpy: 1.14.1
scipy: None
pyarrow: None
xarray: None
IPython: None
sphinx: None
patsy: None
dateutil: 2.6.1
pytz: 2018.3
blosc: None
bottleneck: None
tables: None
numexpr: None
feather: None
matplotlib: None
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: None
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: None
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None
@TomAugspurger

This comment has been minimized.

Copy link
Contributor

commented Mar 1, 2018

Huh. This only affects released versions.

Adding a simplefilter to that catch_warnings block seemed to fix things for a local version.

from warnings import catch_warnings, simplefilter
with catch_warnings(record=True):
    simplefilter('ignore', FutureWarning)
    import json
import sys

@TomAugspurger TomAugspurger added this to the 0.23.0 milestone Mar 1, 2018

@TomAugspurger TomAugspurger added the Build label Mar 1, 2018

@jreback

This comment has been minimized.

Copy link
Contributor

commented Mar 1, 2018

these are going away soon anyhow (0.24). #15537
I suppose you could edit this.

@TomAugspurger TomAugspurger modified the milestones: 0.23.0, Next Major Release Apr 23, 2018

@ManjushaBolishetty

This comment has been minimized.

Copy link

commented Aug 16, 2018

Hey all - just checkin if this issue is closed? I am looking to pick something for a beginner. thank you! Is there a way to know an issue is fixed and closed?

@jorisvandenbossche

This comment has been minimized.

Copy link
Member

commented Aug 16, 2018

This issue is still open, but instead of fixing the warning with the solution mentioned above (#19944 (comment)), I think we would rather just remove the pandas.json module entirely for the next release (but PR welcome for that as well!)

@vitoriahmc

This comment has been minimized.

Copy link
Contributor

commented Sep 10, 2018

Hi there, is anyone currently working on this one? Can I get a try on this last suggestion from @jorisvandenbossche?

@TomAugspurger

This comment has been minimized.

Copy link
Contributor

commented Sep 10, 2018

Looks like no one is working on it, feel free to take it @vitoriahmc.

Let us know if you need help getting started.

@vitoriahmc vitoriahmc referenced this issue Sep 17, 2018

Merged

CLN: Removes module pandas.json #22737

4 of 4 tasks complete

@jreback jreback modified the milestones: Contributions Welcome, 0.24.0 Sep 18, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.