Skip to content

Commit ae17462

Browse files
committed
ENH: ndim tables in HDFStore
changes axes_to_index keyword in table creation to axes allow passing of numeric or named axes (e.g. 0 or 'minor_axis') in axes create_axes now checks for current table scheme; raises if this indexing scheme is violated added many p4d tests for appending/selection/partial selection/and axis permuation added addition Term tests to include p4d add __eq__ operators to IndexCol/DataCol/Table to comparisons updated docs with Panel4D saving & issues relating to threading supporting non-regular indexables: e.g. can index a Panel4D on say [labels,major_axis,minor_axis], rather than the default of [items,major_axis,minor_axis] support column oriented DataFrames (e.g. queryable by the columns)
1 parent f198721 commit ae17462

File tree

3 files changed

+356
-115
lines changed

3 files changed

+356
-115
lines changed

doc/source/io.rst

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1140,15 +1140,17 @@ Delete from a Table
11401140

11411141
.. ipython:: python
11421142
1143+
# returns the number of rows deleted
11431144
store.remove('wp', 'major_axis>20000102' )
11441145
store.select('wp')
11451146
11461147
Notes & Caveats
11471148
~~~~~~~~~~~~~~~
11481149

1149-
- Selection by items (the top level panel dimension) is not possible; you always get all of the items in the returned Panel
11501150
- Once a ``table`` is created its items (Panel) / columns (DataFrame) are fixed; only exactly the same columns can be appended
11511151
- You can not append/select/delete to a non-table (table creation is determined on the first append, or by passing ``table=True`` in a put operation)
1152+
- ``HDFStore`` is **not-threadsafe for writing**. The underlying ``PyTables`` only supports concurrent reads (via threading or processes). If you need reading and writing *at the same time*, you need to serialize these operations in a single thread in a single process. You will corrupt your data otherwise. See the issue <https://github.com/pydata/pandas/issues/2397> for more information.
1153+
11521154
- ``PyTables`` only supports fixed-width string columns in ``tables``. The sizes of a string based indexing column (e.g. *column* or *minor_axis*) are determined as the maximum size of the elements in that axis or by passing the parameter ``min_itemsize`` on the first table creation (``min_itemsize`` can be an integer or a dict of column name to an integer). If subsequent appends introduce elements in the indexing axis that are larger than the supported indexer, an Exception will be raised (otherwise you could have a silent truncation of these indexers, leading to loss of information). This is **ONLY** necessary for storing ``Panels`` (as the indexing column is stored directly in a column)
11531155

11541156
.. ipython:: python
@@ -1183,6 +1185,27 @@ Performance
11831185
use the pytables utilities ``ptrepack`` to rewrite the file (and also can change compression methods)
11841186
- Duplicate rows can be written, but are filtered out in selection (with the last items being selected; thus a table is unique on major, minor pairs)
11851187

1188+
Experimental
1189+
~~~~~~~~~~~~
1190+
1191+
HDFStore supports ``Panel4D`` storage.
1192+
1193+
.. ipython:: python
1194+
1195+
p4d = Panel4D({ 'l1' : wp })
1196+
p4d
1197+
store.append('p4d', p4d)
1198+
store
1199+
1200+
These, by default, index the three axes ``items, major_axis, minor_axis``. On an ``AppendableTable`` it is possible to setup with the first append a different indexing scheme, depending on how you want to store your data. Pass the ``axes`` keyword with a list of dimension (currently must by exactly 1 less than the total dimensions of the object). This cannot be changed after table creation.
1201+
1202+
.. ipython:: python
1203+
1204+
from pandas.io.pytables import Term
1205+
store.append('p4d2', p4d, axes = ['labels','major_axis','minor_axis'])
1206+
store
1207+
store.select('p4d2', [ Term('labels=l1'), Term('items=Item1'), Term('minor_axis=A_big_strings') ])
1208+
11861209
.. ipython:: python
11871210
:suppress:
11881211

0 commit comments

Comments
 (0)