Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
filmor opened this issue Jan 14, 2014 · 2 comments · Fixed by #5935
Closed

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

filmor opened this issue Jan 14, 2014 · 2 comments · Fixed by #5935
Labels
Bug Indexing Related to indexing on series/frames, not to indexes themselves
Milestone

Comments

@filmor
Copy link
Contributor

filmor commented Jan 14, 2014

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.

@filmor
Copy link
Contributor Author

filmor commented Jan 14, 2014

Maybe not, the patch is at filmor@2c9f7d3, but a test fails (https://travis-ci.org/filmor/pandas/jobs/16920606). What is the rationale behind having a dtype for the BlockManager?

@jreback
Copy link
Contributor

jreback commented Jan 14, 2014

@filmor thanks for reporting......BlockManager does not have a dtype. BUT SingleBlockManager provides the property to refer to the dtype of its single block (its the implementation for a series)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Indexing Related to indexing on series/frames, not to indexes themselves
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants