Skip to content

Commit

Permalink
ENH: Make HDFStore iterable
Browse files Browse the repository at this point in the history
  • Loading branch information
toobaz committed Feb 7, 2016
1 parent 70f79ce commit 7fa8a8a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 3 additions & 0 deletions pandas/io/pytables.py
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,9 @@ def keys(self):
"""
return [n._v_pathname for n in self.groups()]

def __iter__(self):
return iter(self.keys())

def items(self):
"""
iterate on key->group
Expand Down
5 changes: 3 additions & 2 deletions pandas/io/tests/test_pytables.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,8 +389,9 @@ def test_keys(self):
store['d'] = tm.makePanel()
store['foo/bar'] = tm.makePanel()
self.assertEqual(len(store), 5)
self.assertTrue(set(
store.keys()) == set(['/a', '/b', '/c', '/d', '/foo/bar']))
expected = set(['/a', '/b', '/c', '/d', '/foo/bar'])
self.assertTrue(set(store.keys()) == expected)
self.assertTrue(set(store) == expected)

def test_repr(self):

Expand Down

0 comments on commit 7fa8a8a

Please sign in to comment.