Skip to content
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

error: Argument 1 to "astype" of "Series" has incompatible type "dtype[generic] | ExtensionDtype"; expected "type[object] | ExtensionDtype" [arg-type] #747

Closed
randolf-scholz opened this issue Jul 18, 2023 · 1 comment · Fixed by #756
Labels
Dtype Conversions Unexpected or buggy dtype conversions good first issue

Comments

@randolf-scholz
Copy link
Contributor

Describe the bug

Series.dtype is incompatible with Series.astype

To Reproduce

import pandas as pd

s = pd.Series([1, 2, 3])
s = s.astype(s.dtype)  # ✘ [arg-type]

Please complete the following information:

  • OS: Ubuntu 22.04
  • python version 3.10
  • mypy 1.4.1
  • pandas 2.0.3
  • pandas-stubs 2.0.2.230605
@Dr-Irv
Copy link
Collaborator

Dr-Irv commented Jul 18, 2023

I think if we replace

| ExtensionDtype

with DtypeObj (and move the definition of DtypeObj above AstypeObj, then this error would get fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Dtype Conversions Unexpected or buggy dtype conversions good first issue
Projects
None yet
2 participants