{"action":"created","issue":{"url":"https://api.github.com/repos/Becksteinlab/MDSynthesis/issues/20","labels_url":"https://api.github.com/repos/Becksteinlab/MDSynthesis/issues/20/labels{/name}","comments_url":"https://api.github.com/repos/Becksteinlab/MDSynthesis/issues/20/comments","events_url":"https://api.github.com/repos/Becksteinlab/MDSynthesis/issues/20/events","html_url":"https://github.com/Becksteinlab/MDSynthesis/issues/20","id":66708303,"number":20,"title":"Storing 1D DataFrame gives Pandas TypeError on retrieval","user":{"login":"cing","id":116655,"avatar_url":"https://avatars.githubusercontent.com/u/116655?v=3","gravatar_id":"","url":"https://api.github.com/users/cing","html_url":"https://github.com/cing","followers_url":"https://api.github.com/users/cing/followers","following_url":"https://api.github.com/users/cing/following{/other_user}","gists_url":"https://api.github.com/users/cing/gists{/gist_id}","starred_url":"https://api.github.com/users/cing/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cing/subscriptions","organizations_url":"https://api.github.com/users/cing/orgs","repos_url":"https://api.github.com/users/cing/repos","events_url":"https://api.github.com/users/cing/events{/privacy}","received_events_url":"https://api.github.com/users/cing/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":{"login":"dotsdl","id":1326811,"avatar_url":"https://avatars.githubusercontent.com/u/1326811?v=3","gravatar_id":"","url":"https://api.github.com/users/dotsdl","html_url":"https://github.com/dotsdl","followers_url":"https://api.github.com/users/dotsdl/followers","following_url":"https://api.github.com/users/dotsdl/following{/other_user}","gists_url":"https://api.github.com/users/dotsdl/gists{/gist_id}","starred_url":"https://api.github.com/users/dotsdl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dotsdl/subscriptions","organizations_url":"https://api.github.com/users/dotsdl/orgs","repos_url":"https://api.github.com/users/dotsdl/repos","events_url":"https://api.github.com/users/dotsdl/events{/privacy}","received_events_url":"https://api.github.com/users/dotsdl/received_events","type":"User","site_admin":false},"milestone":null,"comments":1,"created_at":"2015-04-06T21:19:19Z","updated_at":"2015-04-06T22:07:46Z","closed_at":null,"body":"I'm not exactly sure what's going on here, but I can't store a 1D DataFrame. Retrieving a (10,1) DataFrame gives the error \"TypeError: Index(...) must be called with a collection of some kind, None was passed\":\r\n\r\n```\r\nimport mdsynthesis as mds                                                        \r\nimport numpy as np                                                               \r\nimport pandas as pd                                                              \r\n                                                                                 \r\ns = mds.Sim('marklar')                                                           \r\ns.data.add('test1',pd.DataFrame(np.zeros((1,10))))                                                            \r\nprint s.data[\"test1\"]        #Good\r\n                                                    \r\ns.data.add('test2',pd.Series(np.zeros((10,))))                                                                        \r\nprint s.data[\"test2\"]        #Good\r\n\r\ns.data.add('test3',pd.DataFrame(np.zeros((10,10))))                                                              \r\nprint s.data[\"test3\"]        #Good\r\n\r\ns.data.add('test4',pd.DataFrame(np.zeros((10,1))))                                                              \r\nprint s.data[\"test4\"]        #Not Good\r\n```\r\n\r\nI'm pretty sure this is actually a problem with writing the file to disk because the h5 file seems weird:\r\n```\r\nz=pd.HDFStore(\"test4/pdData.h5\", 'r')\r\n>>> z\r\n<class 'pandas.io.pytables.HDFStore'>\r\nFile path: pdData.h5\r\n/main            [invalid_HDFStore node: sequence item 0: expected string, numpy.int64 found]\r\n```\r\nAny idea how to fix this?"},"comment":{"url":"https://api.github.com/repos/Becksteinlab/MDSynthesis/issues/comments/90259675","html_url":"https://github.com/Becksteinlab/MDSynthesis/issues/20#issuecomment-90259675","issue_url":"https://api.github.com/repos/Becksteinlab/MDSynthesis/issues/20","id":90259675,"user":{"login":"dotsdl","id":1326811,"avatar_url":"https://avatars.githubusercontent.com/u/1326811?v=3","gravatar_id":"","url":"https://api.github.com/users/dotsdl","html_url":"https://github.com/dotsdl","followers_url":"https://api.github.com/users/dotsdl/followers","following_url":"https://api.github.com/users/dotsdl/following{/other_user}","gists_url":"https://api.github.com/users/dotsdl/gists{/gist_id}","starred_url":"https://api.github.com/users/dotsdl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dotsdl/subscriptions","organizations_url":"https://api.github.com/users/dotsdl/orgs","repos_url":"https://api.github.com/users/dotsdl/repos","events_url":"https://api.github.com/users/dotsdl/events{/privacy}","received_events_url":"https://api.github.com/users/dotsdl/received_events","type":"User","site_admin":false},"created_at":"2015-04-06T22:07:46Z","updated_at":"2015-04-06T22:07:46Z","body":"This appears to be due to the defaults chosen for ``pandas`` object storage. The ``MDSynthesis.core.persistence.pdDataFile.add_data`` method first tries to store the object with ``data_columns=True``, which will create an index that allows PyTables ``where`` queries to be performed on columns. However, [this is a problem if column names start with numbers](http://pandas.pydata.org/pandas-docs/dev/io.html#notes-caveats), and so the method falls back on not using ``data_columns=True`` if it fails.\r\n\r\nThis appears to work for all of the DataFrames in this test except for the 1D one. For all of those, an ``AttributeError`` is raised and caught as expected. But for that one, no ``AttributeError`` is raised.\r\n\r\nI'll add a band-aid heuristic to catch this corner case, then I'll submit an issue to pandas to hopefully get it resolved there. Thanks for catching this!"}}