wesm/pandas — Issue #526: DataFrame with 'list of dicts' behaviour proposal
Author: gregglind
Created: 2011-12-22 19:48:24+00:00
State: open

Sketch of proposed behaviour... make 'list of dicts' create a (potentially) 'ragged' array, with autoguessed column names, and sensible default values, when the keys don't exist in all dicts.

Current behaviour:

In [215]: pandas.DataFrame([dict(a=1),dict(a=2)],columns=['a'])
Out[215]:
a
0 {'a': 1}
1 {'a': 2}

(I happen to find this very surprising/useless behaviour!)

(one) Proposed behaviour...

>>> print DataFrame2([dict(a=1,c=1,d=True),dict(b=2,c='abc')])
a c d
0 1 1 True
1 NaN abc NaN

I have a straw implementation at: https://gist.github.com/1511578

(there is a lot to comment on!... should it use the set of keys? Do we need more args? Documentation? Is this just a recipe?)