BUG: Copying an empty DataFrame with index results in a broken BlockManager · Issue #5932 · pandas-dev/pandas (original) (raw)
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.