@@ -282,38 +282,60 @@ def to_hdf(path_or_buf, key, value, mode=None, complevel=None, complib=None,
282
282
283
283
284
284
def read_hdf (path_or_buf , key = None , mode = 'r' , ** kwargs ):
285
- """ read from the store, close it if we opened it
286
-
287
- Retrieve pandas object stored in file, optionally based on where
288
- criteria
285
+ """
286
+ Read from the store, close it if we opened it.
289
287
290
- Parameters
291
- ----------
292
- path_or_buf : path (string), buffer or path object (pathlib.Path or
293
- py._path.local.LocalPath) designating the file to open, or an
294
- already opened pd.HDFStore object
288
+ Retrieve pandas object stored in file, optionally based on where
289
+ criteria
295
290
296
- .. versionadded:: 0.19.0 support for pathlib, py.path.
291
+ Parameters
292
+ ----------
293
+ path_or_buf : string, buffer or path object
294
+ Path to the file to open, or an open :class:`pandas.HDFStore` object.
295
+ Supports any object implementing the ``__fspath__`` protocol.
296
+ This includes :class:`pathlib.Path` and py._path.local.LocalPath
297
+ objects.
298
+
299
+ .. versionadded:: 0.19.0 support for pathlib, py.path.
300
+ .. versionadded:: 0.21.0 support for __fspath__ proptocol.
301
+
302
+ key : object, optional
303
+ The group identifier in the store. Can be omitted if the HDF file
304
+ contains a single pandas object.
305
+ mode : {'r', 'r+', 'a'}, optional
306
+ Mode to use when opening the file. Ignored if path_or_buf is a
307
+ :class:`pandas.HDFStore`. Default is 'r'.
308
+ where : list, optional
309
+ A list of Term (or convertible) objects.
310
+ start : int, optional
311
+ Row number to start selection.
312
+ stop : int, optional
313
+ Row number to stop selection.
314
+ columns : list, optional
315
+ A list of columns names to return.
316
+ iterator : bool, optional
317
+ Return an iterator object.
318
+ chunksize : int, optional
319
+ Number of rows to include in an iteration when using an iterator.
320
+ kwargs : dict
321
+ Additional keyword arguments passed to HDFStore.
297
322
298
- key : group identifier in the store. Can be omitted if the HDF file
299
- contains a single pandas object.
300
- mode : string, {'r', 'r+', 'a'}, default 'r'. Mode to use when opening
301
- the file. Ignored if path_or_buf is a pd.HDFStore.
302
- where : list of Term (or convertible) objects, optional
303
- start : optional, integer (defaults to None), row number to start
304
- selection
305
- stop : optional, integer (defaults to None), row number to stop
306
- selection
307
- columns : optional, a list of columns that if not None, will limit the
308
- return columns
309
- iterator : optional, boolean, return an iterator, default False
310
- chunksize : optional, nrows to include in iteration, return an iterator
323
+ Returns
324
+ -------
325
+ item : object
326
+ The selected object. Return type depends on the object stored.
311
327
312
- Returns
313
- -------
314
- The selected object
328
+ See Also
329
+ --------
330
+ pandas.DataFrame.to_hdf : write a HDF file from a DataFrame
331
+ pandas.HDFStore : low-level access to HDF files
315
332
316
- """
333
+ Examples
334
+ --------
335
+ >>> df = pd.DataFrame([[1, 1.0, 'a']], columns=['x', 'y', 'z'])
336
+ >>> df.to_hdf('./store.h5', 'data')
337
+ >>> reread = pd.read_hdf('./store.h5')
338
+ """
317
339
318
340
if mode not in ['r' , 'r+' , 'a' ]:
319
341
raise ValueError ('mode {0} is not allowed while performing a read. '
0 commit comments