BUG: Fix convert_dtype complex by Ma-gi-cian · Pull Request #62960 · pandas-dev/pandas (original) (raw)

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 andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters

[ Show hidden characters]({{ revealButtonHref }})

@Ma-gi-cian

Changes :

Example script and output :

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

Output :

(pandas-dev) jha@MAGICIAN:~/workspace/opensource/reports/pandas-60129$ python3 main.py 0 0 1.0+5.0j 1 1.5-3.0j

@Ma-gi-cian

@Ma-gi-cian

@Ma-gi-cian

Hi @rhshadrach

Could you review this PR and suggest on any changes if required. I've added the fix as specified - convert_dtypes() now no-ops for complex dtypes.

Thanks

rhshadrach

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good.

@Ma-gi-cian

@Ma-gi-cian

@Ma-gi-cian

Fixed the assert check - should pass all ci now

import pandas as pd

df = pd.DataFrame({"a": [1.0+5.0j, 1.5 - 3.0j], "b": [1,2]}) print(df) print("\n") print(df.dtypes)

      a  b

0 1.0+5.0j 1 1 1.5-3.0j 2

a complex128 b int64 dtype: object

rhshadrach

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@rhshadrach rhshadrach changed the titleFix convert_dtype complex BUG: Fix convert_dtype complex

Nov 18, 2025

@rhshadrach

mittal-aakriti pushed a commit to mittal-aakriti/pandas that referenced this pull request

Nov 19, 2025

@Ma-gi-cian @mittal-aakriti

mittal-aakriti pushed a commit to mittal-aakriti/pandas that referenced this pull request

Nov 19, 2025

@Ma-gi-cian @mittal-aakriti

Labels

2 participants

@Ma-gi-cian @rhshadrach