Skip to content

DEPR: type argument in Index.view #56421

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

Merged
merged 1 commit into from
Dec 9, 2023

Conversation

jbrockmendel
Copy link
Member

@mroeschke
Copy link
Member

Didn't we want to deprecate this entire method or was that just Series.view?

@jbrockmendel
Copy link
Member Author

i tried deprecating the whole method and there were some fiddly Index.is_ issues i decided to punt on

@mroeschke mroeschke added Deprecate Functionality to remove in pandas Index Related to the Index class or subclasses labels Dec 9, 2023
@mroeschke mroeschke added this to the 2.2 milestone Dec 9, 2023
@mroeschke mroeschke merged commit cb56347 into pandas-dev:main Dec 9, 2023
@mroeschke
Copy link
Member

Thanks @jbrockmendel

@@ -1012,6 +1012,16 @@ def view(self, cls=None):

result = self._data.view(cls)
else:
if cls is not None:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is still a if cls is not None and not hasattr(cls, "_typ"): branch above, should passing cls for those cases also be deprecated?
(otherwise we still can't remove the keyword after the current deprecation of this PR is enforced?)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This deprecated passing a type index.view(pd.DatetimeIndex), didnt handle passing a dtype

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I see. But do you know of any usage internally with a dtype?
I know we use it regularly without any argument to get an "identical" object (that passes is_), but I don't directly find much usage with a dtype.

From a quick look (outside of direct tests for this), I only found CategoricalDtype._hash_categories that uses it, where it could easily be avoided.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

id be fine with follow-up(s) to deprecate more/all of this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Deprecate Functionality to remove in pandas Index Related to the Index class or subclasses
Projects
None yet
Development

Successfully merging this pull request may close these issues.

API/DEPR: Index.view _typ check, return type
3 participants