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

Deprecated pandas.io.json.json_normalize : From df = True #40

Open
MJKruskopf opened this issue Jun 22, 2022 · 1 comment
Open

Deprecated pandas.io.json.json_normalize : From df = True #40

MJKruskopf opened this issue Jun 22, 2022 · 1 comment
Labels

Comments

@MJKruskopf
Copy link

I am getting this deprecation message every time I make a call using the df = True for example:

res = api.measurements(country= 'IN', parameter = 'pm25',limit=10000, df=True, date_from='2022-03-01T00:00:00Z',
date_to='2022-04-01T00:00:00Z')

Results in:

/usr/local/lib/python3.7/dist-packages/openaq/decorators.py:37: FutureWarning: pandas.io.json.json_normalize is deprecated, use pandas.json_normalize instead
status, resp = f(*args, **kwargs)

Can this be updated?

@grigsos
Copy link

grigsos commented Apr 11, 2023

I think I made it work, but I'm new so not too sure. Replace the current values

in decorators.py

try:
    import pandas as pd
    from pandas import json_normalize
    _no_pandas = False
except ImportError:
    _no_pandas = True

and

if f.__name__ in ('latest'):
    data.set_index('lastUpdated', inplace=True)
    if 'lastUpdated' in data.columns:
        data.drop('lastUpdated', axis=1, inplace=True)
elif f.__name__ in ('measurements'):
    if index == 'utc':
        data.set_index('date.utc', inplace=True)
        if 'date.utc' in data.columns:
            data.drop('date.utc', axis=1, inplace=True)
    elif index == 'local':
        data.set_index('date.local', inplace=True)
        if 'date.local' in data.columns:
            data.drop('date.local', axis=1, inplace=True)
    else:
        raise ValueError("Index value not recognized.")

@dhhagan dhhagan added the bug label Sep 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants