DEPR: Index.ravel returning an ndarray by jbrockmendel · Pull Request #36900 · pandas-dev/pandas (original) (raw)
I am still skeptical about the need for this method at all
as there is a top level numpy function for this https://numpy.org/doc/stable/reference/generated/numpy.ravel.html.
In the future, with __array_function__ implemented, could allow much simplification of the pandas API.
so I think OK to deprecate the method, in favour of np.ravel() support.
>>> pd.__version__
'1.2.0.dev0+765.g401d7a142c'
>>>
>>> idx = pd.Index([1, 2, 3])
>>>
>>> np.ravel(idx)
array([1, 2, 3], dtype=int64)
>>>
>>> type(_)
<class 'numpy.ndarray'>
>>>
so we could use np.ravel to get the current behaviour, of implement __array_function__ if we wanted to return a Index instead.