Skip to content

BUG: Copying an empty DataFrame with index results in a broken BlockManager #5932

Closed
@filmor

Description

@filmor

The following line illustrates the problem:

df = pd.DataFrame(index=[0]).copy()
df["a"] = 0

This results in an AttributeError since the function BlockManager.make_empty initialises df._data.blocks with a numpy array object instead of an empty list. Thus subsequent calls to blocks.pop and blocks.append fail.

I have a patch coming up.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugIndexingRelated to indexing on series/frames, not to indexes themselves

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions