So, if you do not pass an empty list to the DataFrame constructor, it works:
In [16]: df = pd.DataFrame() h = pd.Series(['g',4,2,1,1]) df = df.append(h,ignore_index=True) df Out[16]: 0 1 2 3 4 0 g 4 2 1 1 [1 rows x 5 columns]
The difference between the two approaches to the constructors is that the dtypes index is specified differently, and the empty list is Int64 , and nothing is object :
In [21]: df = pd.DataFrame() print(df.index.dtype) df = pd.DataFrame([]) print(df.index.dtype) object int64
It is not clear why the above should affect the behavior (I assume here).
UPDATE
After revising this question, I can confirm that this looks like an error in pandas version 0.12.0 , since your source code is working fine:
In [13]: import pandas as pd df = pd.DataFrame([]) h = pd.Series(['g',4,2,1,1]) df.append(h,ignore_index=True) Out[13]: 0 1 2 3 4 0 g 4 2 1 1 [1 rows x 5 columns]
I run pandas 0.13.1 and numpy 1.8.1 64-bit using python 3.3.5.0 , but I think the problem is in pandas, but I would update both pandas and numpy to be safe, I donβt think it is 32 -bit problem with 64-bit python.
source share