py-openaq
py-openaq copied to clipboard
Deprecated pandas.io.json.json_normalize : From df = True
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?
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.")