'Python warning :FutureWarning: Support for multi-dimensional indexing
I am getting below warning for python in console.I did not found any solution for these.We dont want to suppress warnings . Also we have a big code base setup.how to know which code block is cause of this error as warning dont give code line number. I am using below version of python and numpy.Is it due to old verison's of python and numpy.
Python version- 3.6.8 Numpy Version- 1.19.5 matplotlib version is 3.3.4 pandas version is 1.1.5
Warning:
/python3.6/site-packages/matplotlib/cbook/init.py:1402: FutureWarning: Support for multi-dimensional indexing (e.g. obj[:, None]) is deprecated and will be removed in a future version. Convert to a numpy array before indexing instead.
python3.6/site-packages/pandas/core/indexing.py:1743: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,col_indexer] = value instead
Solution 1:[1]
The below works:
import numpy as np
np.array(obj)[:, None]
Solution 2:[2]
It's the way you're accessing the array, using slicing. Matplotlib is going to remove that from how they handle arrays, but they haven't yet. It's just a recommendation to convert to a different type of array access, like Numpy, before that happens. Based of what you're showing, i'd guess it's as simple as 1. Create Numpy Array 2. Use identical slicing except using Numpy syntax. Should be good to go after that I'd imagine.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Vincent Mullers |
| Solution 2 | T_lastname |
