-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
DEPR: Index.ravel returning an ndarray #36900
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
nice! |
@jbrockmendel I don't think there was consensus on changing
|
I would be OK changing the deprecation so to say the future behavior is to match self._values.ravel, matching Series behavior.
The same as the use case for Series.ravel: you want to write code that is ndarray/index/series-agnostic |
IMO that sounds as a better option. Having consistency between Series and Index here would be good I think (although Index is more array-like than Series ..) I am still skeptical about the need for this method at all, though (you can also do a ndim check if you eg want to ensure the array-like is 1D or converted to 1D, see eg Tom's comment at #19956 (comment)) |
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.
so we could use np.ravel to get the current behaviour, of implement __array_function__ if we wanted to return a Index instead. |
Also for Because |
black pandas
git diff upstream/master -u -- "*.py" | flake8 --diff
Make Index.ravel() behavior match every other ravel() method in existence.