Skip to content

DataFrame with 'list of dicts' behaviour proposal #526

Closed
@gregglind

Description

@gregglind

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?)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions