-
-
Notifications
You must be signed in to change notification settings - Fork 18.6k
TYP: require _update_inplace gets Frame/Series, never BlockManager #33074
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -418,10 +418,6 @@ def _set_axis(self, axis: int, labels, fastpath: bool = False) -> None: | |
# The ensure_index call aabove ensures we have an Index object | ||
self._data.set_axis(axis, labels) | ||
|
||
def _update_inplace(self, result, **kwargs): | ||
# we want to call the generic version and not the IndexOpsMixin | ||
return generic.NDFrame._update_inplace(self, result, **kwargs) | ||
|
||
# ndarray compatibility | ||
@property | ||
def dtype(self) -> DtypeObj: | ||
|
@@ -1802,7 +1798,7 @@ def unique(self): | |
result = super().unique() | ||
return result | ||
|
||
def drop_duplicates(self, keep="first", inplace=False) -> "Series": | ||
def drop_duplicates(self, keep="first", inplace=False) -> Optional["Series"]: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. are we actually testing the return value of inplace ops for drop_duplicates / duplciated? IIRC these are actually returning an object (at least they were). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Yes, editing this to return self instead of None breaks a test in tests.frame.test_api |
||
""" | ||
Return Series with duplicate values removed. | ||
|
||
|
@@ -1877,7 +1873,13 @@ def drop_duplicates(self, keep="first", inplace=False) -> "Series": | |
5 hippo | ||
Name: animal, dtype: object | ||
""" | ||
return super().drop_duplicates(keep=keep, inplace=inplace) | ||
inplace = validate_bool_kwarg(inplace, "inplace") | ||
result = super().drop_duplicates(keep=keep) | ||
if inplace: | ||
self._update_inplace(result) | ||
return None | ||
else: | ||
return result | ||
|
||
def duplicated(self, keep="first") -> "Series": | ||
""" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is only used in Index I think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It exists on Series too