{"action":"closed","issue":{"url":"https://api.github.com/repos/pydata/pandas/issues/10514","labels_url":"https://api.github.com/repos/pydata/pandas/issues/10514/labels{/name}","comments_url":"https://api.github.com/repos/pydata/pandas/issues/10514/comments","events_url":"https://api.github.com/repos/pydata/pandas/issues/10514/events","html_url":"https://github.com/pydata/pandas/issues/10514","id":93239499,"number":10514,"title":"DataFrame constructor ignores key order when data is an OrderedDict and orient is 'columns'","user":{"login":"alan-wong","id":2933165,"avatar_url":"https://avatars.githubusercontent.com/u/2933165?v=3","gravatar_id":"","url":"https://api.github.com/users/alan-wong","html_url":"https://github.com/alan-wong","followers_url":"https://api.github.com/users/alan-wong/followers","following_url":"https://api.github.com/users/alan-wong/following{/other_user}","gists_url":"https://api.github.com/users/alan-wong/gists{/gist_id}","starred_url":"https://api.github.com/users/alan-wong/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alan-wong/subscriptions","organizations_url":"https://api.github.com/users/alan-wong/orgs","repos_url":"https://api.github.com/users/alan-wong/repos","events_url":"https://api.github.com/users/alan-wong/events{/privacy}","received_events_url":"https://api.github.com/users/alan-wong/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-07-06T10:09:46Z","updated_at":"2015-07-06T10:31:30Z","closed_at":"2015-07-06T10:31:30Z","body":"Whilst answering this question: http://stackoverflow.com/questions/31242021/python-3-4-pandas-dataframe-not-responding-to-ordered-dictionary\r\n\r\nI had look at this and found the error is in index.py line 5746 on pandas 0.16.2:\r\n\r\n```\r\ndef _union_indexes(indexes):\r\n    if len(indexes) == 0:\r\n        raise AssertionError('Must have at least 1 Index to union')\r\n    if len(indexes) == 1:\r\n        result = indexes[0]\r\n        if isinstance(result, list):\r\n            result = Index(sorted(result)) #<---- here\r\n        return result\r\n```\r\n\r\nminimal example:\r\n\r\n```\r\nIn [38]:\r\nimport pandas as pd\r\nfrom collections import OrderedDict\r\nd = OrderedDict([('XXX', OrderedDict([('B', 1), ('A', 2)]))])\r\npd.DataFrame(d)\r\n\r\nOut[38]:\r\n   XXX\r\nA    2\r\nB    1\r\n```\r\n\r\nThe same thing occurs if you do:\r\n\r\n```\r\npd.DataFrame.from_dict(d)\r\n```\r\n\r\nNote that passing 'orient='index'' preserves the order:\r\n\r\n```\r\nIn [40]:\r\npd.DataFrame.from_dict(d, orient='index')\r\n\r\nOut[40]:\r\n     B  A\r\nXXX  1  2\r\n```"}}