You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
the index that is added is an arbitrary one.
I'd like to use 'order_id' as my index, in this example.
The only way for me to do that at the moment is to create
the index explicitly, e.g. like this:
df = DataFrame(documents, columns=['order_id', 'time', 'quantity'],
index=[o['order_id'] for o in documents])
This is a bit of a PIA. It would be nice if one could just
specify the index key/column name, e.g.
Hey Wes,
Here's a use case that I think is not covered by Pandas.
It's a use case for creation of a DataFrame object from a
list of dicts.
I extract "documents" (dicts) from a MongoDB database.
From these dicts, one of the keys is meant to be used as
the index.
While I can do something like
df = DataFrame(documents, columns=['order_id', 'time', 'quantity'])
the index that is added is an arbitrary one.
I'd like to use 'order_id' as my index, in this example.
The only way for me to do that at the moment is to create
the index explicitly, e.g. like this:
df = DataFrame(documents, columns=['order_id', 'time', 'quantity'],
index=[o['order_id'] for o in documents])
This is a bit of a PIA. It would be nice if one could just
specify the index key/column name, e.g.
df = DataFrame(documents, columns=['order_id', 'time', 'quantity'], indexcol='order_id')
That's my use case almost everywhere.
The text was updated successfully, but these errors were encountered: