diff --git a/ci/code_checks.sh b/ci/code_checks.sh index 5870a9ad8d60b..9453edb0c88d8 100755 --- a/ci/code_checks.sh +++ b/ci/code_checks.sh @@ -108,14 +108,7 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then pandas.read_clipboard \ pandas.ExcelFile \ pandas.ExcelFile.parse \ - pandas.DataFrame.to_html \ pandas.io.formats.style.Styler.to_html \ - pandas.HDFStore.put \ - pandas.HDFStore.append \ - pandas.HDFStore.get \ - pandas.HDFStore.select \ - pandas.HDFStore.info \ - pandas.HDFStore.keys \ pandas.HDFStore.groups \ pandas.HDFStore.walk \ pandas.read_feather \ diff --git a/pandas/core/frame.py b/pandas/core/frame.py index c7e8f74ff7849..68fa0024472f6 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -3127,6 +3127,11 @@ def to_html( See Also -------- to_string : Convert DataFrame to a string. + + Examples + -------- + >>> df = pd.DataFrame([[1, 2], [3, 4]], columns=['A', 'B']) + >>> df.to_html() # doctest: +SKIP """ if justify is not None and justify not in fmt._VALID_JUSTIFY_PARAMETERS: raise ValueError("Invalid value for justify parameter") diff --git a/pandas/io/pytables.py b/pandas/io/pytables.py index c9dab71805b62..c37f2ba5114c4 100644 --- a/pandas/io/pytables.py +++ b/pandas/io/pytables.py @@ -662,6 +662,16 @@ def keys(self, include: str = "pandas") -> list[str]: Raises ------ raises ValueError if kind has an illegal value + + 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 + >>> store.get('data') # doctest: +SKIP + >>> print(store.keys()) # doctest: +SKIP + ['/data1', '/data2'] + >>> store.close() # doctest: +SKIP """ if include == "pandas": return [n._v_pathname for n in self.groups()] @@ -781,6 +791,14 @@ def get(self, key: str): ------- object Same type as object stored in file. + + 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 + >>> store.get('data') # doctest: +SKIP + >>> store.close() # doctest: +SKIP """ with patch_pickle(): # GH#31167 Without this patch, pickle doesn't know how to unpickle @@ -835,6 +853,24 @@ def select( ------- object Retrieved object from file. + + 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 + >>> store.get('data') # doctest: +SKIP + >>> print(store.keys()) # doctest: +SKIP + ['/data1', '/data2'] + >>> store.select('/data1') # doctest: +SKIP + A B + 0 1 2 + 1 3 4 + >>> store.select('/data1', where='columns == A') # doctest: +SKIP + A + 0 1 + 1 3 + >>> store.close() # doctest: +SKIP """ group = self.get_node(key) if group is None: @@ -1107,6 +1143,12 @@ def put( independent on creation time. dropna : bool, default False, optional Remove missing values. + + 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 """ if format is None: format = get_option("io.hdf.default_format") or "fixed" @@ -1243,6 +1285,20 @@ def append( ----- Does *not* check if data being appended overlaps with existing data in the table, so be careful + + 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 + A B + 0 1 2 + 1 3 4 + 0 5 6 + 1 7 8 """ if columns is not None: raise TypeError( @@ -1578,6 +1634,17 @@ def info(self) -> str: Returns ------- str + + 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.info()) # doctest: +SKIP + >>> store.close() # doctest: +SKIP + + File path: store.h5 + /data frame (shape->[2,2]) """ path = pprint_thing(self._path) output = f"{type(self)}\nFile path: {path}\n"