{"action":"created","issue":{"url":"https://api.github.com/repos/pydata/pandas/issues/14173","repository_url":"https://api.github.com/repos/pydata/pandas","labels_url":"https://api.github.com/repos/pydata/pandas/issues/14173/labels{/name}","comments_url":"https://api.github.com/repos/pydata/pandas/issues/14173/comments","events_url":"https://api.github.com/repos/pydata/pandas/issues/14173/events","html_url":"https://github.com/pydata/pandas/issues/14173","id":175464412,"number":14173,"title":"BUG: union_categoricals w/Series & CategoricalIndex","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},"labels":[{"url":"https://api.github.com/repos/pydata/pandas/labels/Bug","name":"Bug","color":"e10c02"},{"url":"https://api.github.com/repos/pydata/pandas/labels/Categorical","name":"Categorical","color":"e11d21"},{"url":"https://api.github.com/repos/pydata/pandas/labels/Difficulty%20Intermediate","name":"Difficulty Intermediate","color":"fbca04"},{"url":"https://api.github.com/repos/pydata/pandas/labels/Effort%20Medium","name":"Effort Medium","color":"006b75"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/pydata/pandas/milestones/40","html_url":"https://github.com/pydata/pandas/milestones/0.19.0","labels_url":"https://api.github.com/repos/pydata/pandas/milestones/40/labels","id":1639795,"number":40,"title":"0.19.0","description":"","creator":{"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},"open_issues":34,"closed_issues":650,"state":"open","created_at":"2016-03-11T21:24:45Z","updated_at":"2016-09-07T10:11:28Z","due_on":"2016-09-27T00:00:00Z","closed_at":null},"comments":4,"created_at":"2016-09-07T10:11:28Z","updated_at":"2016-09-07T10:20:15Z","closed_at":null,"body":"```\r\nIn [25]: from pandas.types.concat import union_categoricals\r\n\r\nIn [26]: s1 = pd.Series(['a', 'b'], dtype='category')\r\n    ...: s3 = pd.Series(['a', 'b', 'c'], dtype='category')\r\n\r\nIn [27]: s1\r\nOut[27]: \r\n0    a\r\n1    b\r\ndtype: category\r\nCategories (2, object): [a, b]\r\n\r\nIn [28]: s3\r\nOut[28]: \r\n0    a\r\n1    b\r\n2    c\r\ndtype: category\r\nCategories (3, object): [a, b, c]\r\n```\r\n\r\nI don't see why this shouldn't work. This should return a Categorical.\r\n```\r\nIn [29]: union_categoricals([s1,s3])\r\nAttributeError: 'Series' object has no attribute 'categories'\r\n```\r\n\r\nactual categoricals are combinable\r\n```\r\nIn [30]: union_categoricals([s1.values,s3.values])\r\nOut[30]: \r\n[a, b, a, b, c]\r\nCategories (3, object): [a, b, c]\r\n```\r\n\r\nThis works fine\r\n```\r\nIn [31]: union_categoricals([s1.values,pd.CategoricalIndex(s3.values)])\r\nOut[31]: \r\n[a, b, a, b, c]\r\nCategories (3, object): [a, b, c]\r\n```\r\n\r\nBut this is broken\r\n```\r\nIn [32]: union_categoricals([pd.CategoricalIndex(s1.values),pd.CategoricalIndex(s3.values)])\r\nAttributeError: 'CategoricalIndex' object has no attribute 'is_dtype_equal'\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/pydata/pandas/issues/comments/245238072","html_url":"https://github.com/pydata/pandas/issues/14173#issuecomment-245238072","issue_url":"https://api.github.com/repos/pydata/pandas/issues/14173","id":245238072,"user":{"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},"created_at":"2016-09-07T10:20:15Z","updated_at":"2016-09-07T10:20:15Z","body":"Yep, I agree that `union_categoricals` should handle categorical serieses"}}
{"actor":{"display_login":"jorisvandenbossche"}}