Repository navigation
Labels
Release criticalFor bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.
Milestone
Description
Bug report
Bug summary
The code below raises DeprecationWarning from pandas=1.0.0rc0 when plt.plot is fed with two pandas.Series (using my matplotlib=3.1.0 instance). It reproduces also when the series is not empty, and also when plotting two different series as x and y.
Code for reproduction
import pandas as pd
import matplotlib.pyplot as plt
x = pd.Series([], dtype="float64")
plt.plot(x, x)Actual outcome
Traceback (most recent call last):
File "pandas1.py", line 5, in <module>
plt.plot(x, x)
File "/lib/python3.7/site-packages/matplotlib/pyplot.py", line 2789, in plot
is not None else {}), **kwargs)
File "/lib/python3.7/site-packages/matplotlib/axes/_axes.py", line 1666, in plot
lines = [*self._get_lines(*args, data=data, **kwargs)]
File "/lib/python3.7/site-packages/matplotlib/axes/_base.py", line 225, in __call__
yield from self._plot_args(this, kwargs)
File "/lib/python3.7/site-packages/matplotlib/axes/_base.py", line 386, in _plot_args
x = _check_1d(tup[0])
File "/lib/python3.7/site-packages/matplotlib/cbook/__init__.py", line 1402, in _check_1d
x[:, None]
File "/lib/python3.7/site-packages/pandas/core/series.py", line 865, in __getitem__
return self._get_with(key)
File "/lib/python3.7/site-packages/pandas/core/series.py", line 878, in _get_with
return self._get_values_tuple(key)
File "/lib/python3.7/site-packages/pandas/core/series.py", line 920, in _get_values_tuple
return self._get_values(key)
File "/lib/python3.7/site-packages/pandas/core/series.py", line 934, in _get_values
self._data.get_slice(indexer), fastpath=True
File "/lib/python3.7/site-packages/pandas/core/internals/managers.py", line 1542, in get_slice
return type(self)(self._block._slice(slobj), self.index[slobj], fastpath=True)
File "/lib/python3.7/site-packages/pandas/core/indexes/range.py", line 708, in __getitem__
return super().__getitem__(key)
File "/lib/python3.7/site-packages/pandas/core/indexes/base.py", line 3908, in __getitem__
deprecate_ndim_indexing(result)
File "/lib/python3.7/site-packages/pandas/core/indexes/base.py", line 5553, in deprecate_ndim_indexing
stacklevel=3,
DeprecationWarning: Support for multi-dimensional indexing (e.g. `index[:, None]`) on an Index is deprecated and will be removed in a future version. Convert to a numpy array before indexing instead.
Expected outcome
No warnings.
Matplotlib version
- Operating system: linux
- Matplotlib version: 3.1.0
- Matplotlib backend (
print(matplotlib.get_backend())): agg - Python version: 3.7.3
- Other libraries: pandas=1.0.0rc0
python and matplotlib obtained through anaconda, pandas through pip
Metadata
Metadata
Assignees
Labels
Release criticalFor bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.
Activity
tacaswell commentedon Jan 27, 2020
This is something we have sort of dealt with before (#14992 / #15007 and pandas-dev/pandas#27775).
Looks like we are ready for the far future after the deprecation is done, but not the near future when it is warning, working on a PR.
FIX: catch warnings from pandas in cbook._check_1d
FIX: catch warnings from pandas in cbook._check_1d
jklymak commentedon Jan 30, 2020
Re-opening because the changes in #16347 don't seem to capture the warning?
FIX: catch on message content, not module
tacaswell commentedon Jan 31, 2020
Well that is deeply odd as the other test that is exercising this code path does pass.
Not sure how I missed this when I did the PR (as it fails on that test but not the other ones on rc0), sorry about that 🐑 .
Something is going wrong with the warning matching, the module filtering is picking up the warning from
RangeIndex, but not from the datetime index.It looks like the stack level stuff is ending up in a c-extension (?) and losing the module information, will report to pandas and have a PR to fix this (again).
Details
jklymak commentedon Jan 31, 2020
Glad you could track it down; I was sure scratching my head....
tacaswell commentedon Jan 31, 2020
On a bit more consideration, I think that the behaviour I was using before is actually the buggy behavior and the one that re-broke us was behaving correctly. It makes sense for pandas to set the stack level to warn where they are being called incorrectly, not where inside of them selves they are letting you know you are using them wrong.
tacaswell commentedon Jan 31, 2020
xref pandas-dev/pandas#31479
FIX: catch on message content, not module
FIX: catch on message content, not module