From 84fc7bf4aaca529f7618d7331fb94d33812ee583 Mon Sep 17 00:00:00 2001 From: DaCoEx Date: Tue, 9 Feb 2016 13:36:39 +0100 Subject: [PATCH 1/4] added pd as namespace more consistent with code in the rest of the document --- doc/source/io.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/source/io.rst b/doc/source/io.rst index 36d4bd89261c4..c824b8646c9bb 100644 --- a/doc/source/io.rst +++ b/doc/source/io.rst @@ -2553,7 +2553,7 @@ for some advanced strategies .. ipython:: python - store = HDFStore('store.h5') + store = pd.HDFStore('store.h5') print(store) Objects can be written to the file just like adding key-value pairs to a @@ -2611,7 +2611,7 @@ Closing a Store, Context Manager # Working with, and automatically closing the store with the context # manager - with HDFStore('store.h5') as store: + with pd.HDFStore('store.h5') as store: store.keys() .. ipython:: python From 01dcacd4d6f0bdf3d0a06265bf56001966b3414d Mon Sep 17 00:00:00 2001 From: dacoex Date: Tue, 9 Feb 2016 15:25:17 +0100 Subject: [PATCH 2/4] added more namespace Generally, also numpy's randn should used as np.random.randn --- doc/source/io.rst | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/doc/source/io.rst b/doc/source/io.rst index c824b8646c9bb..15338392ad09e 100644 --- a/doc/source/io.rst +++ b/doc/source/io.rst @@ -1399,7 +1399,7 @@ Writing to a file, with a date index and a date column dfj2['date'] = Timestamp('20130101') dfj2['ints'] = list(range(5)) dfj2['bools'] = True - dfj2.index = date_range('20130101', periods=5) + dfj2.index = pd.date_range('20130101', periods=5) dfj2.to_json('test.json') open('test.json').read() @@ -2562,7 +2562,7 @@ dict: .. ipython:: python np.random.seed(1234) - index = date_range('1/1/2000', periods=8) + index = pd.date_range('1/1/2000', periods=8) s = Series(randn(5), index=['a', 'b', 'c', 'd', 'e']) df = DataFrame(randn(8, 3), index=index, columns=['A', 'B', 'C']) @@ -2754,7 +2754,7 @@ enable ``put/append/to_hdf`` to by default store in the ``table`` format. .. ipython:: python - store = HDFStore('store.h5') + store = pd.HDFStore('store.h5') df1 = df[0:4] df2 = df[4:] @@ -2801,6 +2801,22 @@ everything in the sub-store and BELOW, so be *careful*. .. _io.hdf5-types: +.. warning:: Hierarchical keys cannot be retrieved as dotted (attribute) access as described above for items stored under root node. + + .. ipython:: python + + store.foo.bar.bah + AttributeError: 'HDFStore' object has no attribute 'foo' + + store.root.foo.bar.bah + /foo/bar/bah (Group) '' + children := ['block0_items' (Array), 'axis1' (Array), 'axis0' (Array), 'block0_values' (Array)] + + + + + + Storing Types ''''''''''''' @@ -3364,7 +3380,7 @@ Compression for all objects within the file .. code-block:: python - store_compressed = HDFStore('store_compressed.h5', complevel=9, complib='blosc') + store_compressed = pd.HDFStore('store_compressed.h5', complevel=9, complib='blosc') Or on-the-fly compression (this only applies to tables). You can turn off file compression for a specific table by passing ``complevel=0`` @@ -3573,7 +3589,7 @@ It is possible to write an ``HDFStore`` object that can easily be imported into index=range(100)) df_for_r.head() - store_export = HDFStore('export.h5') + store_export = pd.HDFStore('export.h5') store_export.append('df_for_r', df_for_r, data_columns=df_dc.columns) store_export @@ -3662,7 +3678,7 @@ number of options, please see the docstring. .. ipython:: python # a legacy store - legacy_store = HDFStore(legacy_file_path,'r') + legacy_store = pd.HDFStore(legacy_file_path,'r') legacy_store # copy (and return the new handle) From dfac360cdd76bbf1fc2b6d58d73819c4a5dd97dc Mon Sep 17 00:00:00 2001 From: dacoex Date: Tue, 9 Feb 2016 15:28:04 +0100 Subject: [PATCH 3/4] added warning for retrieving from groups --- doc/source/io.rst | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/doc/source/io.rst b/doc/source/io.rst index 15338392ad09e..795d6bee25cb6 100644 --- a/doc/source/io.rst +++ b/doc/source/io.rst @@ -2812,10 +2812,12 @@ everything in the sub-store and BELOW, so be *careful*. /foo/bar/bah (Group) '' children := ['block0_items' (Array), 'axis1' (Array), 'axis0' (Array), 'block0_values' (Array)] - - + Use explicit string based keys + .. ipython:: python + bah = store['foo/bar/bah'] + Storing Types ''''''''''''' From ef48a31a2ccf08827256a45a23ca1093ccdfeaf2 Mon Sep 17 00:00:00 2001 From: dacoex Date: Wed, 10 Feb 2016 10:05:58 +0100 Subject: [PATCH 4/4] Revert "added warning for retrieving from groups" This reverts commit dfac360cdd76bbf1fc2b6d58d73819c4a5dd97dc. --- doc/source/io.rst | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/doc/source/io.rst b/doc/source/io.rst index 795d6bee25cb6..15338392ad09e 100644 --- a/doc/source/io.rst +++ b/doc/source/io.rst @@ -2812,12 +2812,10 @@ everything in the sub-store and BELOW, so be *careful*. /foo/bar/bah (Group) '' children := ['block0_items' (Array), 'axis1' (Array), 'axis0' (Array), 'block0_values' (Array)] - Use explicit string based keys + + - .. ipython:: python - bah = store['foo/bar/bah'] - Storing Types '''''''''''''