I upgraded from pandas 0.20.3 to pandas 0.24.1. While running the command ts.sort_index(inplace=True)
, I am getting a FutureWarning
in my test output, which is shown below. Can I change the method call to suppress the following warning? I am happy to keep the old behavior.
/lib/python3.6/site-packages/pandas/core/sorting.py:257: FutureWarning: Converting timezone-aware DatetimeArray to timezone-naive ndarray with 'datetime64[ns]' dtype. In the future, this will return an ndarray with 'object' dtype where each element is a 'pandas.Timestamp' with the correct 'tz'.
To accept the future behavior, pass 'dtype=object'.
To keep the old behavior, pass 'dtype="datetime64[ns]"'.
items = np.asanyarray(items)
My index looks like the following prior to running the sort_index:
ts.index
DatetimeIndex(['2017-07-05 07:00:00+00:00', '2017-07-05 07:15:00+00:00',
'2017-07-05 07:30:00+00:00', '2017-07-05 07:45:00+00:00',
...
'2017-07-05 08:00:00+00:00'],
dtype='datetime64[ns, UTC]', name='start', freq=None)
I rewrote your question here , to include an MCVE. After it went a while with no responses, I posted an issue against Pandas.
Here's my workaround:
with warnings.catch_warnings():
# Bug in Pandas emits useless warning when sorting tz-aware index
warnings.simplefilter("ignore")
ds = df.sort_index()
If I were you, I would do a downgrade using pip and setting the previous version. It's the lazier answer. But if you really want to keep it upgraded, then there is a parameter call deprecated warning inside pandas data frame. Just adjust it accordingly what you need. You can check it using the documentation of pandas. Have a nice night
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.