Skip to content

TYP: Extend typing to allow passing Index to_datetime #38634

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

Conversation

josh-friedlander-kando
Copy link
Contributor

ArrayConvertible should be able to accept Index or Series type as well
This extends it to use AnyArrayLike instead of ArrayLike.

  • [ x] passes black pandas
  • [ x] passes git diff upstream/master -u -- "*.py" | flake8 --diff

@jreback jreback added the Typing type annotations, mypy/pyright type checking label Dec 22, 2020
@josh-friedlander-kando
Copy link
Contributor Author

Ah sorry, it failed isort because the import I added was out of order (should be alphabetical: AnyArrayLike, ArrayLike).

ArrayConvertible should be able to accept Index or Series type as well
This extends it to use AnyArrayLike instead of ArrayLike.
@josh-friedlander-kando
Copy link
Contributor Author

josh-friedlander-kando commented Dec 23, 2020

The motivation for this is that a pretty common action
df.index = pd.to_datetime(df.index)
is marked by my IDE (PyCharm 2020.3.1 Professional Edition) as a type error, since to_datetime accepts a list/tuple/Series/DateTimeScalar, but not an Index. The change doesn't seem to break anything else.

@jreback jreback added this to the 1.3 milestone Dec 23, 2020
@jreback jreback merged commit 94e3284 into pandas-dev:master Dec 23, 2020
@jreback
Copy link
Contributor

jreback commented Dec 23, 2020

thanks @josh-friedlander-kando

@josh-friedlander-kando josh-friedlander-kando deleted the change_datetime_type branch December 24, 2020 09:53
luckyvs1 pushed a commit to luckyvs1/pandas that referenced this pull request Jan 20, 2021
@josh-friedlander-kando josh-friedlander-kando restored the change_datetime_type branch April 14, 2021 07:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Typing type annotations, mypy/pyright type checking
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants