Skip to content

Conversation

@Ma-gi-cian
Copy link

@Ma-gi-cian Ma-gi-cian commented Nov 2, 2025

Changes :

  • Modified pandas/core/dtypes/cast.py to preserve complex dtypes (kind 'c') instead of attempting to convert them
  • Since there is no Numpy-nullable complex array nor a PyArrow complex dtype, this is effectively a no-op (leaves complex data as-is)
  • Removed 'c' (complex) from dtype kind checks where it was incorrectly grouped with floats
  • Added tests for both DataFrame.convert_dtypes() and Series.convert_dtypes() with complex data

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BUG: allow complex type in convert_dtypes

1 participant