Skip to content

DataFrame constructor bug from single Series with different Index #475

@wesm

Description

@wesm

reported by a user


In [7]: DataFrame(Series(np.arange(10)), index=range(5))
---------------------------------------------------------------------------
AssertionError                            Traceback (most recent call last)
/home/wesm/code/pandas/<ipython-input-7-0a85de6b44f0> in <module>()
----> 1 DataFrame(Series(np.arange(10)), index=range(5))

/home/wesm/code/pandas/pandas/core/frame.pyc in __init__(self, data, index, columns, dtype, copy)
    206             else:
    207                 mgr = self._init_ndarray(data, index, columns, dtype=dtype,
--> 208                                          copy=copy)
    209         elif isinstance(data, list):                                                     
    210             mgr = self._init_ndarray(data, index, columns, dtype=dtype,

/home/wesm/code/pandas/pandas/core/frame.pyc in _init_ndarray(self, values, index, columns, dtype, copy)                                                                                          
    287         columns = _ensure_index(columns)
    288         block = make_block(values.T, columns, columns)
--> 289         return BlockManager([block], [columns, index])
    290 
    291     def _wrap_array(self, arr, axes, copy=False):

/home/wesm/code/pandas/pandas/core/internals.pyc in __init__(self, blocks, axes, do_integrity_check)                                                                                              
    274 
    275         if do_integrity_check:
--> 276             self._verify_integrity()
    277 
    278     @property

/home/wesm/code/pandas/pandas/core/internals.pyc in _verify_integrity(self)
    353         mgr_shape = self.shape
    354         for block in self.blocks:
--> 355             assert(block.values.shape[1:] == mgr_shape[1:])
    356         tot_items = sum(len(x.items) for x in self.blocks)
    357         assert(len(self.items) == tot_items)

AssertionError: 

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