Skip to content

Commit 157e97b

Browse files
authored
DOC: fixed Ex03 errors in docstrings: pandas.io.formats.style.Styler.to_latex and pandas.read_parquet (#56953)
Addressing validation errors
1 parent 24f6139 commit 157e97b

File tree

3 files changed

+17
-12
lines changed

3 files changed

+17
-12
lines changed

ci/code_checks.sh

-2
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
7777
pandas.errors.SpecificationError \
7878
pandas.errors.UndefinedVariableError \
7979
pandas.read_json \
80-
pandas.io.formats.style.Styler.to_latex \
81-
pandas.read_parquet \
8280
pandas.DataFrame.to_sql \
8381
RET=$(($RET + $?)) ; echo $MSG "DONE"
8482

pandas/io/formats/style.py

+12-9
Original file line numberDiff line numberDiff line change
@@ -987,11 +987,11 @@ def to_latex(
987987
hide the repeated level-0 of the index:
988988
989989
>>> (styler.format(subset="Equity", precision=2)
990-
... .format(subset="Stats", precision=1, thousands=",")
991-
... .format(subset="Rating", formatter=str.upper)
992-
... .format_index(escape="latex", axis=1)
993-
... .format_index(escape="latex", axis=0)
994-
... .hide(level=0, axis=0)) # doctest: +SKIP
990+
... .format(subset="Stats", precision=1, thousands=",")
991+
... .format(subset="Rating", formatter=str.upper)
992+
... .format_index(escape="latex", axis=1)
993+
... .format_index(escape="latex", axis=0)
994+
... .hide(level=0, axis=0)) # doctest: +SKIP
995995
996996
Note that one of the string entries of the index and column headers is "H&M".
997997
Without applying the `escape="latex"` option to the `format_index` method the
@@ -1003,12 +1003,15 @@ def to_latex(
10031003
recommendation:
10041004
10051005
>>> def rating_color(v):
1006-
... if v == "Buy": color = "#33ff85"
1007-
... elif v == "Sell": color = "#ff5933"
1008-
... else: color = "#ffdd33"
1006+
... if v == "Buy":
1007+
... color = "#33ff85"
1008+
... elif v == "Sell":
1009+
... color = "#ff5933"
1010+
... else:
1011+
... color = "#ffdd33"
10091012
... return f"color: {color}; font-weight: bold;"
10101013
>>> (styler.background_gradient(cmap="inferno", subset="Equity", vmin=0, vmax=1)
1011-
... .map(rating_color, subset="Rating")) # doctest: +SKIP
1014+
... .map(rating_color, subset="Rating")) # doctest: +SKIP
10121015
10131016
All the above styles will work with HTML (see below) and LaTeX upon conversion:
10141017

pandas/io/parquet.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,9 @@ def read_parquet(
510510
"""
511511
Load a parquet object from the file path, returning a DataFrame.
512512
513+
The function automatically handles reading the data from a parquet file
514+
and creates a DataFrame with the appropriate structure.
515+
513516
Parameters
514517
----------
515518
path : str, path object or file-like object
@@ -591,6 +594,7 @@ def read_parquet(
591594
Returns
592595
-------
593596
DataFrame
597+
DataFrame based on parquet file.
594598
595599
See Also
596600
--------
@@ -600,7 +604,7 @@ def read_parquet(
600604
--------
601605
>>> original_df = pd.DataFrame(
602606
... {{"foo": range(5), "bar": range(5, 10)}}
603-
... )
607+
... )
604608
>>> original_df
605609
foo bar
606610
0 0 5

0 commit comments

Comments
 (0)