-
- Notifications
You must be signed in to change notification settings - Fork 19.4k
TYP: ExtensionArray delete() and searchsorted() #41513
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
1bf4b5d 16bcc1a c0d426f cce79a9 0a9cd7a f37d215 22b147a 065454f cde198e b986eba 2d85ddb 493ab41 f8f8b93 704abef f8d4267 9c391a0 4e60e04 6a888ef 2370384 42802ec 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 |
|---|---|---|
| | @@ -29,6 +29,7 @@ | |
| FillnaOptions, | ||
| PositionalIndexer, | ||
| Shape, | ||
| npt, | ||
| ) | ||
| from pandas.compat import set_function_name | ||
| from pandas.compat.numpy import function as nv | ||
| | @@ -81,6 +82,11 @@ def any(self, *, skipna: bool = True) -> bool: | |
| def all(self, *, skipna: bool = True) -> bool: | ||
| pass | ||
| | ||
| from pandas._typing import ( | ||
| NumpySorter, | ||
| NumpyValueArrayLike, | ||
| ) | ||
| | ||
| | ||
| _extension_array_shared_docs: dict[str, str] = {} | ||
| | ||
| | @@ -807,7 +813,12 @@ def unique(self: ExtensionArrayT) -> ExtensionArrayT: | |
| uniques = unique(self.astype(object)) | ||
| return self._from_sequence(uniques, dtype=self.dtype) | ||
| | ||
| def searchsorted(self, value, side="left", sorter=None): | ||
| def searchsorted( | ||
| self, | ||
| value: NumpyValueArrayLike | ExtensionArray, | ||
| side: Literal["left", "right"] = "left", | ||
| sorter: NumpySorter = None, | ||
| ) -> npt.NDArray[np.intp] | np.intp: | ||
| """ | ||
| Find indices where elements should be inserted to maintain order. | ||
| | ||
| | @@ -838,8 +849,9 @@ def searchsorted(self, value, side="left", sorter=None): | |
| | ||
| Returns | ||
| ------- | ||
| array of ints | ||
| Array of insertion points with the same shape as `value`. | ||
| array of ints or int | ||
| If value is array-like, array of insertion points. | ||
| If value is scalar, a single integer. | ||
| | ||
| See Also | ||
| -------- | ||
| | @@ -1304,7 +1316,7 @@ def _reduce(self, name: str, *, skipna: bool = True, **kwargs): | |
| # ------------------------------------------------------------------------ | ||
| # Non-Optimized Default Methods | ||
| | ||
| def delete(self: ExtensionArrayT, loc) -> ExtensionArrayT: | ||
| def delete(self: ExtensionArrayT, loc: PositionalIndexer) -> ExtensionArrayT: | ||
| Member 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. This is in the 'public' base EA class. it was added in #39405. @jbrockmendel is this method public? Is it part of the EA interface? does it need a docstring? Member 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. good catch ill make a note to add a docstring | ||
| indexer = np.delete(np.arange(len(self)), loc) | ||
| return self.take(indexer) | ||
| | ||
| | ||
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 npt._SortSide? we probably don't want to use private aliases in the codebase, but maybe OK to do so in pandas._typing. thoughts?
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.
Can't use
_SortSidefrom numpy as it is only defined in theirpyifiles