Skip to content

Initializing a Series with an OrderedDict #3282

@xapple

Description

@xapple

When executing this example code, the graph produced has the columns resorted such that they read ["col1", "col10", "col11", "col2", ...] instead of the correctly sorted ["col1", "col2", "col3", "col4", ...]

from collections import OrderedDict
import pandas, random
data = OrderedDict([('col%s' % i, random.random()) for i in range(12)])
series = pandas.Series(data)
series.plot(kind='bar', color='gray')

test

Of course, the problem is solved by doing:

 series = pandas.Series(data.values(), index=data.keys())

Just thought you would want to fix that though.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions