pandas.HDFStore.select_as_multiple#
- HDFStore.select_as_multiple(keys, where=None, selector=None, columns=None, start=None, stop=None, iterator=False, chunksize=None, auto_close=False)[source]#
Retrieve pandas objects from multiple tables.
Warning
Pandas uses PyTables for reading and writing HDF5 files, which allows serializing object-dtype data with pickle when using the “fixed” format. Loading pickled data received from untrusted sources can be unsafe.
See: https://docs.python.org/3/library/pickle.html for more.
- Parameters:
- keyslist of str
Names of the tables to read.
- wherelist, optional
List of Term (or convertible) objects.
- selectorstr, optional
The table to apply the where criteria to. Defaults to
keys[0].- columnslist, optional
Columns to return.
- startint, optional
Row number to start selection. Applied to each table before
whereis evaluated.- stopint, optional
Row number to stop selection. Applied to each table before
whereis evaluated.- iteratorbool, default False
Return an iterator.
- chunksizeint, optional
Number of rows to include in each iteration; implies
iterator=True.- auto_closebool, default False
Should automatically close the store when finished.
- Returns:
- DataFrame or TableIterator
Concatenated result from the selected tables. A
TableIteratoris returned instead wheniterator=Trueorchunksizeis given.
- Raises:
- KeyError
If
keysorselectoris not found, orkeysis empty.- TypeError
If
keysis not a list or tuple.- ValueError
If the tables do not all have the same number of rows.
See also
HDFStore.append_to_multipleAppend to multiple tables, splitting a single object into a dict of column groups.
HDFStore.selectRetrieve a single stored object.
Examples
>>> df1 = pd.DataFrame([[1, 2], [3, 4]], columns=["A", "B"]) >>> df2 = pd.DataFrame([[5, 6], [7, 8]], columns=["C", "D"]) >>> store = pd.HDFStore("store.h5", "w") >>> store.append("t1", df1, format="table") >>> store.append("t2", df2, format="table") >>> store.select_as_multiple(["t1", "t2"]) >>> store.close()