Skip to content

Commit cc20ddc

Browse files
DeaMariaLeonim-vinicius
authored and
im-vinicius
committed
DOC: Fixing EX01 - Added examples (pandas-dev#53883)
* Examples to_html, put, append * Examples to_html, put, append, get, select, info, keys * Correct select & keys
1 parent 946d056 commit cc20ddc

File tree

3 files changed

+72
-7
lines changed

3 files changed

+72
-7
lines changed

ci/code_checks.sh

-7
Original file line numberDiff line numberDiff line change
@@ -108,14 +108,7 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
108108
pandas.read_clipboard \
109109
pandas.ExcelFile \
110110
pandas.ExcelFile.parse \
111-
pandas.DataFrame.to_html \
112111
pandas.io.formats.style.Styler.to_html \
113-
pandas.HDFStore.put \
114-
pandas.HDFStore.append \
115-
pandas.HDFStore.get \
116-
pandas.HDFStore.select \
117-
pandas.HDFStore.info \
118-
pandas.HDFStore.keys \
119112
pandas.HDFStore.groups \
120113
pandas.HDFStore.walk \
121114
pandas.read_feather \

pandas/core/frame.py

+5
Original file line numberDiff line numberDiff line change
@@ -3127,6 +3127,11 @@ def to_html(
31273127
See Also
31283128
--------
31293129
to_string : Convert DataFrame to a string.
3130+
3131+
Examples
3132+
--------
3133+
>>> df = pd.DataFrame([[1, 2], [3, 4]], columns=['A', 'B'])
3134+
>>> df.to_html() # doctest: +SKIP
31303135
"""
31313136
if justify is not None and justify not in fmt._VALID_JUSTIFY_PARAMETERS:
31323137
raise ValueError("Invalid value for justify parameter")

pandas/io/pytables.py

+67
Original file line numberDiff line numberDiff line change
@@ -662,6 +662,16 @@ def keys(self, include: str = "pandas") -> list[str]:
662662
Raises
663663
------
664664
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
665675
"""
666676
if include == "pandas":
667677
return [n._v_pathname for n in self.groups()]
@@ -781,6 +791,14 @@ def get(self, key: str):
781791
-------
782792
object
783793
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
784802
"""
785803
with patch_pickle():
786804
# GH#31167 Without this patch, pickle doesn't know how to unpickle
@@ -835,6 +853,24 @@ def select(
835853
-------
836854
object
837855
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
838874
"""
839875
group = self.get_node(key)
840876
if group is None:
@@ -1107,6 +1143,12 @@ def put(
11071143
independent on creation time.
11081144
dropna : bool, default False, optional
11091145
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
11101152
"""
11111153
if format is None:
11121154
format = get_option("io.hdf.default_format") or "fixed"
@@ -1243,6 +1285,20 @@ def append(
12431285
-----
12441286
Does *not* check if data being appended overlaps with existing
12451287
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
12461302
"""
12471303
if columns is not None:
12481304
raise TypeError(
@@ -1578,6 +1634,17 @@ def info(self) -> str:
15781634
Returns
15791635
-------
15801636
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])
15811648
"""
15821649
path = pprint_thing(self._path)
15831650
output = f"{type(self)}\nFile path: {path}\n"

0 commit comments

Comments
 (0)