Skip to content

Commit 74f0111

Browse files
Michaeljreback
authored andcommitted
added a note on index creation for pandas dataframe stored in hdf5 file
1 parent 2b0886c commit 74f0111

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

doc/source/cookbook.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1128,6 +1128,16 @@ Storing Attributes to a group node
11281128
store.close()
11291129
os.remove('test.h5')
11301130
1131+
How to construct an index of a Pandas dataframe stored in HDF5 file. This operation is useful after you append multiple data to the dataframe without index creation. The index creation is purposely turned off during appending to save costly computation time
1132+
.. ipython:: python
1133+
1134+
df = DataFrame(randn(10,2),columns=list('AB')).to_hdf('test.h5','df',data_columns=['B'],mode='w',table=True)
1135+
store = pd.HDFStore('test.h5')
1136+
1137+
# create index
1138+
store.create_table_index('df',columns=['B'],optlevel=9,kind='full')
1139+
store.close()
1140+
11311141
11321142
.. _cookbook.binary:
11331143

0 commit comments

Comments
 (0)