Skip to content
Advertisement

Tag: ordereddictionary

Converting a iterable of ordered dict’s to pandas dataframe

I am iterating over OrderedDict’s and want to store them as pandas dataframe. Is there a commend to do that? Currently, the code is: One row in res looks like this: OrderedDict([(‘field_id’, 1), (‘date’, datetime.date(2016, 1, 3)), (‘temp’, 30.08), (‘norm_temperature’, None), (‘prcp’, 12.8848107785339), (‘abcd’, 0.0), (‘efgh’, None), (‘ijkl’, 1.38), (‘lmno’, None), (‘poq’, None)]) I get this error: *** TypeError: data

How can you slice with string keys instead of integers on a python OrderedDict?

Since an OrderedDict has the features of both a list (with ordered elements), and a dictionary (with keys instead of indexes), it would seem natural that you could slice using keys. What’s interesting about this is that it’s not the error you’d see due to OrderedDictionary.__getslice__ not being implemented. I tried adding my own __getslice__ method to OrderedDict, but I

Advertisement