-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
TYP: Update input of core.algorithms.duplicated
#42657
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
lilisako
commented
Jul 22, 2021
•
edited
Loading
edited
- closes TYP: Improve typing on pandas.core.algorithms.duplicated() #42604
- tests added / passed
- Ensure all linting tests pass, see here for how to run them
- whatsnew entry
core.algorithms.duplicated
core.algorithms.duplicated
pandas/core/algorithms.py
Outdated
@@ -903,7 +904,8 @@ def value_counts_arraylike(values, dropna: bool): | |||
|
|||
|
|||
def duplicated( | |||
values: ArrayLike, keep: Literal["first", "last", False] = "first" | |||
values: np.ndarray | ExtensionArray | 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.
ArrayLike
is a alias for np.ndarray | ExtensionArray
and can union aliases with other types
values: np.ndarray | ExtensionArray | Series, | |
values: ArrayLike | Series, |
AnyArrayLike
also includes Index (as well as Series). Is an Index not a valid type here?
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.
@simonjayhawkins
Thanks for the review!
AnyArrayLike also includes Index (as well as Series). Is an Index not a valid type here?
I checked index type and it seems duplicated function accepts one.
import pandas as pd
from pandas.core.algorithms import duplicated
index = pd.Index([1,2,3,4,2,3,1])
duplicated(index)
>> array([False, False, False, False, True, True, True])
Maybe it will be like this?
values: np.ndarray | ExtensionArray | Series, | |
values: AnyArrayLike, |
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.
Great. can you also update the parameters section of the docsting.
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.
Yes! I have pushed the code with those change as well!
This pull request is stale because it has been open for thirty days with no activity. Please update or respond to this comment if you're still interested in working on this. |
Thanks for the pull request, but although its still a draft, it has appeared to have gone stale. If you're still interested in working on this let us know and we can reopen. |