Skip to content

Commit a351e94

Browse files
committed
ENH: treat complex number in internals.form_blocks
1 parent ba08846 commit a351e94

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

pandas/core/internals.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -980,13 +980,16 @@ def form_blocks(data, axes):
980980
# put "leftover" items in float bucket, where else?
981981
# generalize?
982982
float_dict = {}
983+
complex_dict = {}
983984
int_dict = {}
984985
bool_dict = {}
985986
object_dict = {}
986987
datetime_dict = {}
987988
for k, v in data.iteritems():
988989
if issubclass(v.dtype.type, np.floating):
989990
float_dict[k] = v
991+
elif issubclass(v.dtype.type, np.complexfloating):
992+
complex_dict[k] = v
990993
elif issubclass(v.dtype.type, np.datetime64):
991994
datetime_dict[k] = v
992995
elif issubclass(v.dtype.type, np.integer):
@@ -1001,6 +1004,10 @@ def form_blocks(data, axes):
10011004
float_block = _simple_blockify(float_dict, items, np.float64)
10021005
blocks.append(float_block)
10031006

1007+
if len(complex_dict):
1008+
complex_block = _simple_blockify(complex_dict, items, np.complex64)
1009+
blocks.append(complex_block)
1010+
10041011
if len(int_dict):
10051012
int_block = _simple_blockify(int_dict, items, np.int64)
10061013
blocks.append(int_block)

0 commit comments

Comments
 (0)