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

BUG: allow complex type in convert_dtypes #60129

Open
1 of 3 tasks
yasirroni opened this issue Oct 30, 2024 · 1 comment
Open
1 of 3 tasks

BUG: allow complex type in convert_dtypes #60129

yasirroni opened this issue Oct 30, 2024 · 1 comment
Labels
Bug Complex Complex Numbers Dtype Conversions Unexpected or buggy dtype conversions

Comments

@yasirroni
Copy link

Feature Type

  • Adding new functionality to pandas

  • Changing existing functionality in pandas

  • Removing existing functionality in pandas

Problem Description

convert_dtypes should be able to do this type of coercion from string complex looking

print(pd.DataFrame(['1.0+5j', '1.5-3j']).astype(complex).convert_dtypes())

Related to closed #4895

Feature Description

Alternative Solutions

Additional Context

No response

@yasirroni yasirroni added Enhancement Needs Triage Issue that has not been reviewed by a pandas team member labels Oct 30, 2024
@rhshadrach
Copy link
Member

rhshadrach commented Nov 2, 2024

I'm positive on convert_dtypes supporting complex, currently it raises TypeError: complex128 cannot be converted to FloatingDtype if input has complex dtype. There is no Numpy-nullable complex array nor a PyArrow complex dtype, so for both backends this will be a noop (leaves complex data as-is).

convert_dtypes should be able to do this type of coercion from string complex looking

convert_dtypes does not convert strings to non-strings, so the current behavior of pd.DataFrame(['1.0+5j', '1.5-3j']).convert_dtypes() looks correct to me.

@rhshadrach rhshadrach added Bug Dtype Conversions Unexpected or buggy dtype conversions Complex Complex Numbers and removed Enhancement labels Nov 2, 2024
@rhshadrach rhshadrach changed the title ENH: allow complex type inference in convert_dtypes BUG: allow complex type in convert_dtypes Nov 2, 2024
@rhshadrach rhshadrach removed the Needs Triage Issue that has not been reviewed by a pandas team member label Nov 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Complex Complex Numbers Dtype Conversions Unexpected or buggy dtype conversions
Projects
None yet
Development

No branches or pull requests

2 participants