{"action":"created","issue":{"url":"https://api.github.com/repos/pydata/pandas/issues/14216","repository_url":"https://api.github.com/repos/pydata/pandas","labels_url":"https://api.github.com/repos/pydata/pandas/issues/14216/labels{/name}","comments_url":"https://api.github.com/repos/pydata/pandas/issues/14216/comments","events_url":"https://api.github.com/repos/pydata/pandas/issues/14216/events","html_url":"https://github.com/pydata/pandas/issues/14216","id":176776804,"number":14216,"title":"Inconsistent type casting between DataFrame and Series","user":{"login":"dwyatte","id":2512762,"avatar_url":"https://avatars.githubusercontent.com/u/2512762?v=3","gravatar_id":"","url":"https://api.github.com/users/dwyatte","html_url":"https://github.com/dwyatte","followers_url":"https://api.github.com/users/dwyatte/followers","following_url":"https://api.github.com/users/dwyatte/following{/other_user}","gists_url":"https://api.github.com/users/dwyatte/gists{/gist_id}","starred_url":"https://api.github.com/users/dwyatte/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dwyatte/subscriptions","organizations_url":"https://api.github.com/users/dwyatte/orgs","repos_url":"https://api.github.com/users/dwyatte/repos","events_url":"https://api.github.com/users/dwyatte/events{/privacy}","received_events_url":"https://api.github.com/users/dwyatte/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/pydata/pandas/labels/API%20Design","name":"API Design","color":"AD7FA8"},{"url":"https://api.github.com/repos/pydata/pandas/labels/Dtypes","name":"Dtypes","color":"e102d8"},{"url":"https://api.github.com/repos/pydata/pandas/labels/Duplicate","name":"Duplicate","color":"009800"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/pydata/pandas/milestones/33","html_url":"https://github.com/pydata/pandas/milestones/No%20action","labels_url":"https://api.github.com/repos/pydata/pandas/milestones/33/labels","id":997544,"number":33,"title":"No action","description":"A milestone for closed or open issues for which there is no action needed (eg not a bug, just a question / discussion, nothing to resolve, wontfix, etc).\r\n\r\n","creator":{"login":"jorisvandenbossche","id":1020496,"avatar_url":"https://avatars.githubusercontent.com/u/1020496?v=3","gravatar_id":"","url":"https://api.github.com/users/jorisvandenbossche","html_url":"https://github.com/jorisvandenbossche","followers_url":"https://api.github.com/users/jorisvandenbossche/followers","following_url":"https://api.github.com/users/jorisvandenbossche/following{/other_user}","gists_url":"https://api.github.com/users/jorisvandenbossche/gists{/gist_id}","starred_url":"https://api.github.com/users/jorisvandenbossche/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jorisvandenbossche/subscriptions","organizations_url":"https://api.github.com/users/jorisvandenbossche/orgs","repos_url":"https://api.github.com/users/jorisvandenbossche/repos","events_url":"https://api.github.com/users/jorisvandenbossche/events{/privacy}","received_events_url":"https://api.github.com/users/jorisvandenbossche/received_events","type":"User","site_admin":false},"open_issues":3,"closed_issues":350,"state":"open","created_at":"2015-02-26T19:29:05Z","updated_at":"2016-09-14T08:13:29Z","due_on":null,"closed_at":null},"comments":4,"created_at":"2016-09-13T23:28:06Z","updated_at":"2016-09-14T10:12:24Z","closed_at":null,"body":"There is an inconsistency between how Series and DataFrames export types to dicts. The issue only manifests if the dataframe has multiple columns with different types. I think the issue is probably pretty far under the surface with differences between Series and DataFrame dtypes and just happened to be uncovered by export to dict.\r\n\r\n#### Code Sample, a copy-pastable example if possible\r\n```\r\nimport pandas as pd\r\n\r\norig_dict = [{0: 'a', 1: 1}]\r\n\r\n# does not happen with\r\n# orig_dict =[{0: 0, 1: 1}]\r\n\r\nprint 'Original dict'\r\nfor k in orig_dict[0]:\r\n\tprint type(orig_dict[0][k])\r\nprint\r\n\r\ndf = pd.DataFrame(orig_dict)\r\ndict_exported_from_dataframe = [df.loc[[x]].to_dict(orient='records')[0] for x in df.index]\r\ndict_exported_from_series = [df.loc[x].to_dict() for x in df.index]\r\n\r\nprint 'Dict exported from DataFrame'\r\nfor k in dict_exported_from_dataframe[0]:\r\n\tprint type(dict_exported_from_dataframe[0][k])\r\nprint\r\n\r\nprint 'Dict exported from Series'\r\nfor k in dict_exported_from_series[0]:\r\n\tprint type(dict_exported_from_series[0][k])\r\nprint\r\n```\r\n\r\n#### Expected Output\r\n```\r\nOriginal dict\r\n<type 'str'>\r\n<type 'int'>\r\n\r\nDict exported from DataFrame\r\n<type 'str'>\r\n<type 'int'>\r\n\r\nDict exported from Series\r\n<type 'str'>\r\n<type 'int'>\r\n```\r\n\r\nOR\r\n\r\n```\r\nOriginal dict\r\n<type 'str'>\r\n<type 'int'>\r\n\r\nDict exported from DataFrame\r\n<type 'str'>\r\n<type 'numpy.int64'>\r\n\r\nDict exported from Series\r\n<type 'str'>\r\n<type 'numpy.int64'>\r\n```\r\n\r\n#### output of ``pd.show_versions()``\r\nINSTALLED VERSIONS\r\n------------------\r\ncommit: None\r\npython: 2.7.10.final.0\r\npython-bits: 64\r\nOS: Darwin\r\nOS-release: 14.5.0\r\nmachine: x86_64\r\nprocessor: i386\r\nbyteorder: little\r\nLC_ALL: None\r\nLANG: en_US.UTF-8\r\n\r\npandas: 0.18.1\r\nnose: None\r\npip: 8.1.2\r\nsetuptools: 25.2.0\r\nCython: None\r\nnumpy: 1.11.1\r\nscipy: 0.13.0b1\r\nstatsmodels: None\r\nxarray: None\r\nIPython: 5.1.0\r\nsphinx: None\r\npatsy: None\r\ndateutil: 2.5.3\r\npytz: 2016.6.1\r\nblosc: None\r\nbottleneck: None\r\ntables: None\r\nnumexpr: None\r\nmatplotlib: None\r\nopenpyxl: None\r\nxlrd: None\r\nxlwt: None\r\nxlsxwriter: None\r\nlxml: None\r\nbs4: None\r\nhtml5lib: None\r\nhttplib2: None\r\napiclient: None\r\nsqlalchemy: None\r\npymysql: None\r\npsycopg2: None\r\njinja2: None\r\nboto: None\r\npandas_datareader: None\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/pydata/pandas/issues/comments/246967190","html_url":"https://github.com/pydata/pandas/issues/14216#issuecomment-246967190","issue_url":"https://api.github.com/repos/pydata/pandas/issues/14216","id":246967190,"user":{"login":"jreback","id":953992,"avatar_url":"https://avatars.githubusercontent.com/u/953992?v=3","gravatar_id":"","url":"https://api.github.com/users/jreback","html_url":"https://github.com/jreback","followers_url":"https://api.github.com/users/jreback/followers","following_url":"https://api.github.com/users/jreback/following{/other_user}","gists_url":"https://api.github.com/users/jreback/gists{/gist_id}","starred_url":"https://api.github.com/users/jreback/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jreback/subscriptions","organizations_url":"https://api.github.com/users/jreback/orgs","repos_url":"https://api.github.com/users/jreback/repos","events_url":"https://api.github.com/users/jreback/events{/privacy}","received_events_url":"https://api.github.com/users/jreback/received_events","type":"User","site_admin":false},"created_at":"2016-09-14T10:12:24Z","updated_at":"2016-09-14T10:12:24Z","body":"right I didn't repurpose that issue. The underlying, which is slated for 0.20 is #13258 "}}
{"actor":{"display_login":"jreback"}}