Skip to content

Commit e005cbe

Browse files
tkfwesm
authored andcommitted
ENH: treat complex number in internals.form_blocks
1 parent 1ccd286 commit e005cbe

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

pandas/core/internals.py

+7
Original file line numberDiff line numberDiff line change
@@ -987,13 +987,16 @@ def form_blocks(data, axes):
987987
# put "leftover" items in float bucket, where else?
988988
# generalize?
989989
float_dict = {}
990+
complex_dict = {}
990991
int_dict = {}
991992
bool_dict = {}
992993
object_dict = {}
993994
datetime_dict = {}
994995
for k, v in data.iteritems():
995996
if issubclass(v.dtype.type, np.floating):
996997
float_dict[k] = v
998+
elif issubclass(v.dtype.type, np.complexfloating):
999+
complex_dict[k] = v
9971000
elif issubclass(v.dtype.type, np.datetime64):
9981001
datetime_dict[k] = v
9991002
elif issubclass(v.dtype.type, np.integer):
@@ -1008,6 +1011,10 @@ def form_blocks(data, axes):
10081011
float_block = _simple_blockify(float_dict, items, np.float64)
10091012
blocks.append(float_block)
10101013

1014+
if len(complex_dict):
1015+
complex_block = _simple_blockify(complex_dict, items, np.complex64)
1016+
blocks.append(complex_block)
1017+
10111018
if len(int_dict):
10121019
int_block = _simple_blockify(int_dict, items, np.int64)
10131020
blocks.append(int_block)

0 commit comments

Comments
 (0)