From 86a73c28a462c19482610e1dfe674ff8e95f08ca Mon Sep 17 00:00:00 2001 From: Kevin Sheppard Date: Mon, 30 Apr 2018 08:44:10 +0100 Subject: [PATCH 1/3] DOC: Fix read_hdf docstring Read HDF docstring was not in NumPy format. Corrects the formatting [skip ci] --- pandas/io/pytables.py | 73 +++++++++++++++++++++++++++---------------- 1 file changed, 46 insertions(+), 27 deletions(-) diff --git a/pandas/io/pytables.py b/pandas/io/pytables.py index 4004a6ea8f6ff..277d47ccbedcc 100644 --- a/pandas/io/pytables.py +++ b/pandas/io/pytables.py @@ -282,38 +282,57 @@ def to_hdf(path_or_buf, key, value, mode=None, complevel=None, complib=None, def read_hdf(path_or_buf, key=None, mode='r', **kwargs): - """ read from the store, close it if we opened it - - Retrieve pandas object stored in file, optionally based on where - criteria + """ + Read from the store, close it if we opened it. - Parameters - ---------- - path_or_buf : path (string), buffer or path object (pathlib.Path or - py._path.local.LocalPath) designating the file to open, or an - already opened pd.HDFStore object + Retrieve pandas object stored in file, optionally based on where + criteria - .. versionadded:: 0.19.0 support for pathlib, py.path. + Parameters + ---------- + path_or_buf : string, buffer or path object + Path to the file to open, or an open pd.HDFStore object. + Supports pathlib.Path and py._path.local.LocalPath. + + .. versionadded:: 0.19.0 support for pathlib, py.path. + + key : object, optional + The group identifier in the store. Can be omitted if the HDF file + contains a single pandas object. + mode : {'r', 'r+', 'a'}, optional + Mode to use when opening the file. Ignored if path_or_buf is a + pd.HDFStore. Default is 'r'. + where : list, optional + A list of Term (or convertible) objects. + start : int, optional + Row number to start selection. + stop : int, optional + Row number to stop selection. + columns : list, optional + A list of columns names to return. + iterator : bool, optional + Return an iterator object. + chunksize : int, optional + Number of rows to include in an iteration when using an iterator. + kwargs : dict + Additional keyword arguments passed to HDFStore. - key : group identifier in the store. Can be omitted if the HDF file - contains a single pandas object. - mode : string, {'r', 'r+', 'a'}, default 'r'. Mode to use when opening - the file. Ignored if path_or_buf is a pd.HDFStore. - where : list of Term (or convertible) objects, optional - start : optional, integer (defaults to None), row number to start - selection - stop : optional, integer (defaults to None), row number to stop - selection - columns : optional, a list of columns that if not None, will limit the - return columns - iterator : optional, boolean, return an iterator, default False - chunksize : optional, nrows to include in iteration, return an iterator + Returns + ------- + item : object + The selected object. Return type depends on the object stored. - Returns - ------- - The selected object + See Also + -------- + pandas.DataFrame.to_hdf : write a HDF file from a DataFrame + pandas.HDFStore : low-level access to HDF files - """ + Examples + -------- + >>> df = pd.DataFrame([[1, 1.0, 'a']], columns=['x', 'y', 'z']) + >>> df.to_hdf('./store.h5', 'data') + >>> reread = pd.read_hdf('./store.h5') + """ if mode not in ['r', 'r+', 'a']: raise ValueError('mode {0} is not allowed while performing a read. ' From 4778feb2e0058262150875f3c82d5ef76fc79c56 Mon Sep 17 00:00:00 2001 From: Tom Augspurger Date: Mon, 30 Apr 2018 07:44:35 -0500 Subject: [PATCH 2/3] Trigger CI From c1fb4c45df987638144adb2b8a958b817482f663 Mon Sep 17 00:00:00 2001 From: Tom Augspurger Date: Mon, 30 Apr 2018 07:50:02 -0500 Subject: [PATCH 3/3] DOC: small fixups --- pandas/io/pytables.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/pandas/io/pytables.py b/pandas/io/pytables.py index 277d47ccbedcc..78436bd74ec09 100644 --- a/pandas/io/pytables.py +++ b/pandas/io/pytables.py @@ -291,17 +291,20 @@ def read_hdf(path_or_buf, key=None, mode='r', **kwargs): Parameters ---------- path_or_buf : string, buffer or path object - Path to the file to open, or an open pd.HDFStore object. - Supports pathlib.Path and py._path.local.LocalPath. + Path to the file to open, or an open :class:`pandas.HDFStore` object. + Supports any object implementing the ``__fspath__`` protocol. + This includes :class:`pathlib.Path` and py._path.local.LocalPath + objects. .. versionadded:: 0.19.0 support for pathlib, py.path. + .. versionadded:: 0.21.0 support for __fspath__ proptocol. key : object, optional The group identifier in the store. Can be omitted if the HDF file contains a single pandas object. mode : {'r', 'r+', 'a'}, optional Mode to use when opening the file. Ignored if path_or_buf is a - pd.HDFStore. Default is 'r'. + :class:`pandas.HDFStore`. Default is 'r'. where : list, optional A list of Term (or convertible) objects. start : int, optional