@@ -662,6 +662,16 @@ def keys(self, include: str = "pandas") -> list[str]:
662
662
Raises
663
663
------
664
664
raises ValueError if kind has an illegal value
665
+
666
+ Examples
667
+ --------
668
+ >>> df = pd.DataFrame([[1, 2], [3, 4]], columns=['A', 'B'])
669
+ >>> store = pd.HDFStore("store.h5", 'w') # doctest: +SKIP
670
+ >>> store.put('data', df) # doctest: +SKIP
671
+ >>> store.get('data') # doctest: +SKIP
672
+ >>> print(store.keys()) # doctest: +SKIP
673
+ ['/data1', '/data2']
674
+ >>> store.close() # doctest: +SKIP
665
675
"""
666
676
if include == "pandas" :
667
677
return [n ._v_pathname for n in self .groups ()]
@@ -781,6 +791,14 @@ def get(self, key: str):
781
791
-------
782
792
object
783
793
Same type as object stored in file.
794
+
795
+ Examples
796
+ --------
797
+ >>> df = pd.DataFrame([[1, 2], [3, 4]], columns=['A', 'B'])
798
+ >>> store = pd.HDFStore("store.h5", 'w') # doctest: +SKIP
799
+ >>> store.put('data', df) # doctest: +SKIP
800
+ >>> store.get('data') # doctest: +SKIP
801
+ >>> store.close() # doctest: +SKIP
784
802
"""
785
803
with patch_pickle ():
786
804
# GH#31167 Without this patch, pickle doesn't know how to unpickle
@@ -835,6 +853,24 @@ def select(
835
853
-------
836
854
object
837
855
Retrieved object from file.
856
+
857
+ Examples
858
+ --------
859
+ >>> df = pd.DataFrame([[1, 2], [3, 4]], columns=['A', 'B'])
860
+ >>> store = pd.HDFStore("store.h5", 'w') # doctest: +SKIP
861
+ >>> store.put('data', df) # doctest: +SKIP
862
+ >>> store.get('data') # doctest: +SKIP
863
+ >>> print(store.keys()) # doctest: +SKIP
864
+ ['/data1', '/data2']
865
+ >>> store.select('/data1') # doctest: +SKIP
866
+ A B
867
+ 0 1 2
868
+ 1 3 4
869
+ >>> store.select('/data1', where='columns == A') # doctest: +SKIP
870
+ A
871
+ 0 1
872
+ 1 3
873
+ >>> store.close() # doctest: +SKIP
838
874
"""
839
875
group = self .get_node (key )
840
876
if group is None :
@@ -1107,6 +1143,12 @@ def put(
1107
1143
independent on creation time.
1108
1144
dropna : bool, default False, optional
1109
1145
Remove missing values.
1146
+
1147
+ Examples
1148
+ --------
1149
+ >>> df = pd.DataFrame([[1, 2], [3, 4]], columns=['A', 'B'])
1150
+ >>> store = pd.HDFStore("store.h5", 'w') # doctest: +SKIP
1151
+ >>> store.put('data', df) # doctest: +SKIP
1110
1152
"""
1111
1153
if format is None :
1112
1154
format = get_option ("io.hdf.default_format" ) or "fixed"
@@ -1243,6 +1285,20 @@ def append(
1243
1285
-----
1244
1286
Does *not* check if data being appended overlaps with existing
1245
1287
data in the table, so be careful
1288
+
1289
+ Examples
1290
+ --------
1291
+ >>> df1 = pd.DataFrame([[1, 2], [3, 4]], columns=['A', 'B'])
1292
+ >>> store = pd.HDFStore("store.h5", 'w') # doctest: +SKIP
1293
+ >>> store.put('data', df1, format='table') # doctest: +SKIP
1294
+ >>> df2 = pd.DataFrame([[5, 6], [7, 8]], columns=['A', 'B'])
1295
+ >>> store.append('data', df2) # doctest: +SKIP
1296
+ >>> store.close() # doctest: +SKIP
1297
+ A B
1298
+ 0 1 2
1299
+ 1 3 4
1300
+ 0 5 6
1301
+ 1 7 8
1246
1302
"""
1247
1303
if columns is not None :
1248
1304
raise TypeError (
@@ -1578,6 +1634,17 @@ def info(self) -> str:
1578
1634
Returns
1579
1635
-------
1580
1636
str
1637
+
1638
+ Examples
1639
+ --------
1640
+ >>> df = pd.DataFrame([[1, 2], [3, 4]], columns=['A', 'B'])
1641
+ >>> store = pd.HDFStore("store.h5", 'w') # doctest: +SKIP
1642
+ >>> store.put('data', df) # doctest: +SKIP
1643
+ >>> print(store.info()) # doctest: +SKIP
1644
+ >>> store.close() # doctest: +SKIP
1645
+ <class 'pandas.io.pytables.HDFStore'>
1646
+ File path: store.h5
1647
+ /data frame (shape->[2,2])
1581
1648
"""
1582
1649
path = pprint_thing (self ._path )
1583
1650
output = f"{ type (self )} \n File path: { path } \n "
0 commit comments