Skip to content

Commit

Permalink
ENH: treat complex number in internals.form_blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
tkf committed Apr 20, 2012
1 parent ba08846 commit a351e94
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions pandas/core/internals.py
Original file line number Diff line number Diff line change
Expand Up @@ -980,13 +980,16 @@ def form_blocks(data, axes):
# put "leftover" items in float bucket, where else?
# generalize?
float_dict = {}
complex_dict = {}
int_dict = {}
bool_dict = {}
object_dict = {}
datetime_dict = {}
for k, v in data.iteritems():
if issubclass(v.dtype.type, np.floating):
float_dict[k] = v
elif issubclass(v.dtype.type, np.complexfloating):
complex_dict[k] = v
elif issubclass(v.dtype.type, np.datetime64):
datetime_dict[k] = v
elif issubclass(v.dtype.type, np.integer):
Expand All @@ -1001,6 +1004,10 @@ def form_blocks(data, axes):
float_block = _simple_blockify(float_dict, items, np.float64)
blocks.append(float_block)

if len(complex_dict):
complex_block = _simple_blockify(complex_dict, items, np.complex64)
blocks.append(complex_block)

if len(int_dict):
int_block = _simple_blockify(int_dict, items, np.int64)
blocks.append(int_block)
Expand Down

0 comments on commit a351e94

Please sign in to comment.