Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/source/whatsnew/v0.17.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -866,3 +866,4 @@ Bug Fixes
- Bug in plotting functions may raise ``IndexError`` when plotted on ``GridSpec`` (:issue:`10819`)
- Bug in plot result may show unnecessary minor ticklabels (:issue:`10657`)
- Bug when constructing ``DataFrame`` where passing a dictionary with only scalar values and specifying columns did not raise an error (:issue:`10856`)
- Bug when constructing ``DataFrame`` with an array of complex64 dtype that meant the corresponding column was automatically promoted to the complex128 dtype (:issue:`10952`)
3 changes: 1 addition & 2 deletions pandas/core/internals.py
Original file line number Diff line number Diff line change
Expand Up @@ -3657,8 +3657,7 @@ def form_blocks(arrays, names, axes):
blocks.extend(float_blocks)

if len(complex_items):
complex_blocks = _simple_blockify(
complex_items, np.complex128)
complex_blocks = _multi_blockify(complex_items)
blocks.extend(complex_blocks)

if len(int_items):
Expand Down
9 changes: 9 additions & 0 deletions pandas/tests/test_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -2668,6 +2668,15 @@ def _check_mixed_dtypes(df, dtypes = None):
df = _make_mixed_dtypes_df('int')
_check_mixed_dtypes(df)

def test_constructor_complex_dtypes(self):
# GH10952
a = np.random.rand(10).astype(np.complex64)
b = np.random.rand(10).astype(np.complex128)

df = DataFrame({'a': a, 'b': b})
self.assertEqual(a.dtype, df.a.dtype)
self.assertEqual(b.dtype, df.b.dtype)

def test_constructor_rec(self):
rec = self.frame.to_records(index=False)

Expand Down