From 03306c75a797c51fab2e3e6805446875bfdf3f7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dea=20Mar=C3=ADa=20L=C3=A9on?= Date: Tue, 27 Jun 2023 21:22:22 +0200 Subject: [PATCH] Examples HDFStore.groups, walk --- pandas/io/pytables.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/pandas/io/pytables.py b/pandas/io/pytables.py index c37f2ba5114c4..a67ff5274e0f7 100644 --- a/pandas/io/pytables.py +++ b/pandas/io/pytables.py @@ -1476,6 +1476,17 @@ def groups(self) -> list: ------- list List of objects. + + Examples + -------- + >>> df = pd.DataFrame([[1, 2], [3, 4]], columns=['A', 'B']) + >>> store = pd.HDFStore("store.h5", 'w') # doctest: +SKIP + >>> store.put('data', df) # doctest: +SKIP + >>> print(store.groups()) # doctest: +SKIP + >>> store.close() # doctest: +SKIP + [/data (Group) '' + children := ['axis0' (Array), 'axis1' (Array), 'block0_values' (Array), + 'block0_items' (Array)]] """ _tables() self._check_if_open() @@ -1520,6 +1531,18 @@ def walk(self, where: str = "/") -> Iterator[tuple[str, list[str], list[str]]]: Names (strings) of the groups contained in `path`. leaves : list Names (strings) of the pandas objects contained in `path`. + + Examples + -------- + >>> df1 = pd.DataFrame([[1, 2], [3, 4]], columns=['A', 'B']) + >>> store = pd.HDFStore("store.h5", 'w') # doctest: +SKIP + >>> store.put('data', df1, format='table') # doctest: +SKIP + >>> df2 = pd.DataFrame([[5, 6], [7, 8]], columns=['A', 'B']) + >>> store.append('data', df2) # doctest: +SKIP + >>> store.close() # doctest: +SKIP + >>> for group in store.walk(): # doctest: +SKIP + ... print(group) # doctest: +SKIP + >>> store.close() # doctest: +SKIP """ _tables() self._check_if_open()