{"action":"created","issue":{"url":"https://api.github.com/repos/pydata/pandas/issues/12570","repository_url":"https://api.github.com/repos/pydata/pandas","labels_url":"https://api.github.com/repos/pydata/pandas/issues/12570/labels{/name}","comments_url":"https://api.github.com/repos/pydata/pandas/issues/12570/comments","events_url":"https://api.github.com/repos/pydata/pandas/issues/12570/events","html_url":"https://github.com/pydata/pandas/issues/12570","id":139604621,"number":12570,"title":"read_msgpack can't parse categorical data","user":{"login":"pwaller","id":438648,"avatar_url":"https://avatars.githubusercontent.com/u/438648?v=3","gravatar_id":"","url":"https://api.github.com/users/pwaller","html_url":"https://github.com/pwaller","followers_url":"https://api.github.com/users/pwaller/followers","following_url":"https://api.github.com/users/pwaller/following{/other_user}","gists_url":"https://api.github.com/users/pwaller/gists{/gist_id}","starred_url":"https://api.github.com/users/pwaller/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pwaller/subscriptions","organizations_url":"https://api.github.com/users/pwaller/orgs","repos_url":"https://api.github.com/users/pwaller/repos","events_url":"https://api.github.com/users/pwaller/events{/privacy}","received_events_url":"https://api.github.com/users/pwaller/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/pydata/pandas/labels/Duplicate","name":"Duplicate","color":"009800"},{"url":"https://api.github.com/repos/pydata/pandas/labels/Enhancement","name":"Enhancement","color":"4E9A06"},{"url":"https://api.github.com/repos/pydata/pandas/labels/Msgpack","name":"Msgpack","color":"eb6420"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2016-03-09T15:16:27Z","updated_at":"2016-03-09T15:20:55Z","closed_at":"2016-03-09T15:18:59Z","body":"#### A copy-pastable code sample\r\n\r\n```python\r\nimport pandas\r\nc = pandas.Categorical([\"A\", \"B\", \"C\", \"D\"], categories=[\"A\", \"B\", \"C\", \"D\"])\r\ndf = pandas.DataFrame({\"x\": c})\r\nbytes = df.to_msgpack()\r\npandas.read_msgpack(bytes)\r\n```\r\n\r\n#### What happens\r\n\r\n```pytb\r\n<ipython-input-1-ec1dc8306f4c> in <module>()\r\n      1 import pandas\r\n      2 df = pandas.DataFrame({\"x\": pandas.Categorical([\"A\", \"B\", \"C\", \"D\"], categories=[\"A\", \"B\", \"C\", \"D\"])})\r\n----> 3 pandas.read_msgpack(df.to_msgpack())\r\n\r\n/home/pwaller/.local/lib/python3.4/site-packages/pandas/io/packers.py in read_msgpack(path_or_buf, encoding, iterator, **kwargs)\r\n    153         try:\r\n    154             fh = compat.BytesIO(path_or_buf)\r\n--> 155             return read(fh)\r\n    156         finally:\r\n    157             if fh is not None:\r\n\r\n/home/pwaller/.local/lib/python3.4/site-packages/pandas/io/packers.py in read(fh)\r\n    131 \r\n    132     def read(fh):\r\n--> 133         l = list(unpack(fh, encoding=encoding, **kwargs))\r\n    134         if len(l) == 1:\r\n    135             return l[0]\r\n\r\npandas/msgpack/_unpacker.pyx in pandas.msgpack._unpacker.Unpacker.__next__ (pandas/msgpack/_unpacker.cpp:5277)()\r\n\r\npandas/msgpack/_unpacker.pyx in pandas.msgpack._unpacker.Unpacker._unpack (pandas/msgpack/_unpacker.cpp:4268)()\r\n\r\n/home/pwaller/.local/lib/python3.4/site-packages/pandas/io/packers.py in decode(obj)\r\n    526                               placement=placement)\r\n    527 \r\n--> 528         blocks = [create_block(b) for b in obj['blocks']]\r\n    529         return globals()[obj['klass']](BlockManager(blocks, axes))\r\n    530     elif typ == 'datetime':\r\n\r\n/home/pwaller/.local/lib/python3.4/site-packages/pandas/io/packers.py in <listcomp>(.0)\r\n    526                               placement=placement)\r\n    527 \r\n--> 528         blocks = [create_block(b) for b in obj['blocks']]\r\n    529         return globals()[obj['klass']](BlockManager(blocks, axes))\r\n    530     elif typ == 'datetime':\r\n\r\n/home/pwaller/.local/lib/python3.4/site-packages/pandas/io/packers.py in create_block(b)\r\n    513 \r\n    514         def create_block(b):\r\n--> 515             values = unconvert(b['values'], dtype_for(b['dtype']),\r\n    516                                b['compress']).reshape(b['shape'])\r\n    517 \r\n\r\n/home/pwaller/.local/lib/python3.4/site-packages/pandas/io/packers.py in dtype_for(t)\r\n    181     if t in dtype_dict:\r\n    182         return dtype_dict[t]\r\n--> 183     return np.typeDict[t]\r\n    184 \r\n    185 c2f_dict = {'complex': np.float64,\r\n\r\nKeyError: 'category'\r\n```\r\n\r\n#### Expected Output\r\n\r\nA DataFrame containing a categorical variable `x`.\r\n\r\n#### output of ``pd.show_versions()``\r\n\r\n**Note** I have also tested 0.18.0rc1.\r\n\r\n```\r\nINSTALLED VERSIONS\r\n------------------\r\ncommit: None\r\npython: 3.4.3.final.0\r\npython-bits: 64\r\nOS: Linux\r\nOS-release: 4.2.0-30-generic\r\nmachine: x86_64\r\nprocessor: x86_64\r\nbyteorder: little\r\nLC_ALL: None\r\nLANG: en_GB.UTF-8\r\n\r\npandas: 0.17.1\r\nnose: 1.3.6\r\npip: 8.1.0\r\nsetuptools: 20.0\r\nCython: 0.23.4\r\nnumpy: 1.10.2\r\nscipy: 0.16.1\r\nstatsmodels: 0.6.1\r\nIPython: 4.1.1\r\nsphinx: None\r\npatsy: 0.4.1\r\ndateutil: 2.5.0\r\npytz: 2015.7\r\nblosc: None\r\nbottleneck: None\r\ntables: 3.2.2\r\nnumexpr: 2.4.6\r\nmatplotlib: 1.5.0\r\nopenpyxl: None\r\nxlrd: None\r\nxlwt: None\r\nxlsxwriter: 0.7.3\r\nlxml: None\r\nbs4: 4.3.2\r\nhtml5lib: 0.999\r\nhttplib2: 0.9\r\napiclient: None\r\nsqlalchemy: 1.0.11\r\npymysql: None\r\npsycopg2: None\r\nJinja2: None\r\n```\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/pydata/pandas/issues/comments/194341107","html_url":"https://github.com/pydata/pandas/issues/12570#issuecomment-194341107","issue_url":"https://api.github.com/repos/pydata/pandas/issues/12570","id":194341107,"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-03-09T15:20:55Z","updated_at":"2016-03-09T15:20:55Z","body":"yeah that's the PR, I updated to include the original issue."}}