Skip to content

DataFrame constructor error unhelpful #3105

Closed
@wesm

Description

@wesm
pd.DataFrame(np.arange(12).reshape((4, 3)), columns=['foo', 'bar', 'baz'],
             index=pd.date_range('2000-01-01', periods=3))
---------------------------------------------------------------------------
AssertionError                            Traceback (most recent call last)
<ipython-input-80-77df75afb13d> in <module>()
      1 pd.DataFrame(np.arange(12).reshape((4, 3)), columns=['foo', 'bar', 'baz'],
----> 2              index=pd.date_range('2000-01-01', periods=3))

/Users/wesm/code/pandas/pandas/core/frame.pyc in __init__(self, data, index, columns, dtype, copy)
    408             else:
    409                 mgr = self._init_ndarray(data, index, columns, dtype=dtype,
--> 410                                          copy=copy)
    411         elif isinstance(data, list):
    412             if len(data) > 0:

/Users/wesm/code/pandas/pandas/core/frame.pyc in _init_ndarray(self, values, index, columns, dtype, copy)
    555 
    556         block = make_block(values.T, columns, columns)
--> 557         return BlockManager([block], [columns, index])
    558 
    559     def _wrap_array(self, arr, axes, copy=False):

/Users/wesm/code/pandas/pandas/core/internals.pyc in __init__(self, blocks, axes, do_integrity_check)
    826 
    827         if do_integrity_check:
--> 828             self._verify_integrity()
    829 
    830         self._consolidate_check()

/Users/wesm/code/pandas/pandas/core/internals.pyc in _verify_integrity(self)
    916                                      "items")
    917             if block.values.shape[1:] != mgr_shape[1:]:
--> 918                 raise AssertionError('Block shape incompatible with manager')
    919         tot_items = sum(len(x.items) for x in self.blocks)
    920         if len(self.items) != tot_items:

AssertionError: Block shape incompatible with manager

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions