Skip to content

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

Closed
wants to merge 3 commits into from
Closed

TYP: Update input of core.algorithms.duplicated #42657

wants to merge 3 commits into from

Conversation

lilisako
Copy link

@lilisako lilisako commented Jul 22, 2021

@lilisako lilisako changed the title Update input of core.algorithms.duplicated TYP: Update input of core.algorithms.duplicated Jul 22, 2021
@@ -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,
Copy link
Member

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

Suggested change
values: np.ndarray | ExtensionArray | Series,
values: ArrayLike | Series,

AnyArrayLike also includes Index (as well as Series). Is an Index not a valid type here?

Copy link
Author

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?

Suggested change
values: np.ndarray | ExtensionArray | Series,
values: AnyArrayLike,

Copy link
Member

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.

Copy link
Author

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!

@simonjayhawkins simonjayhawkins added the Typing type annotations, mypy/pyright type checking label Jul 22, 2021
@lilisako lilisako marked this pull request as draft July 27, 2021 09:44
@github-actions
Copy link
Contributor

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.

@github-actions github-actions bot added the Stale label Aug 27, 2021
@mroeschke
Copy link
Member

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.

@mroeschke mroeschke closed this Sep 8, 2021
@lilisako lilisako deleted the issue42604 branch September 8, 2021 02:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Stale Typing type annotations, mypy/pyright type checking
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TYP: Improve typing on pandas.core.algorithms.duplicated()
3 participants