Skip to content

Commit e721af6

Browse files
authored
DOC: Fixing EX01 - Added examples (#53889)
Examples HDFStore.groups, walk
1 parent c739f0e commit e721af6

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

pandas/io/pytables.py

+23
Original file line numberDiff line numberDiff line change
@@ -1476,6 +1476,17 @@ def groups(self) -> list:
14761476
-------
14771477
list
14781478
List of objects.
1479+
1480+
Examples
1481+
--------
1482+
>>> df = pd.DataFrame([[1, 2], [3, 4]], columns=['A', 'B'])
1483+
>>> store = pd.HDFStore("store.h5", 'w') # doctest: +SKIP
1484+
>>> store.put('data', df) # doctest: +SKIP
1485+
>>> print(store.groups()) # doctest: +SKIP
1486+
>>> store.close() # doctest: +SKIP
1487+
[/data (Group) ''
1488+
children := ['axis0' (Array), 'axis1' (Array), 'block0_values' (Array),
1489+
'block0_items' (Array)]]
14791490
"""
14801491
_tables()
14811492
self._check_if_open()
@@ -1520,6 +1531,18 @@ def walk(self, where: str = "/") -> Iterator[tuple[str, list[str], list[str]]]:
15201531
Names (strings) of the groups contained in `path`.
15211532
leaves : list
15221533
Names (strings) of the pandas objects contained in `path`.
1534+
1535+
Examples
1536+
--------
1537+
>>> df1 = pd.DataFrame([[1, 2], [3, 4]], columns=['A', 'B'])
1538+
>>> store = pd.HDFStore("store.h5", 'w') # doctest: +SKIP
1539+
>>> store.put('data', df1, format='table') # doctest: +SKIP
1540+
>>> df2 = pd.DataFrame([[5, 6], [7, 8]], columns=['A', 'B'])
1541+
>>> store.append('data', df2) # doctest: +SKIP
1542+
>>> store.close() # doctest: +SKIP
1543+
>>> for group in store.walk(): # doctest: +SKIP
1544+
... print(group) # doctest: +SKIP
1545+
>>> store.close() # doctest: +SKIP
15231546
"""
15241547
_tables()
15251548
self._check_if_open()

0 commit comments

Comments
 (0)