diff --git a/pandas/core/generic.py b/pandas/core/generic.py index 96abd98bbdd75..0369de8db1339 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -3329,7 +3329,7 @@ def to_latex( >>> print(df.to_latex(index=False, ... formatters={"name": str.upper}, ... float_format="{:.1f}".format, - ... ) # doctest: +SKIP + ... )) # doctest: +SKIP \begin{tabular}{lrr} \toprule name & age & height \\ diff --git a/pandas/errors/__init__.py b/pandas/errors/__init__.py index bb1905ccd4740..3ecee50ffbaa7 100644 --- a/pandas/errors/__init__.py +++ b/pandas/errors/__init__.py @@ -455,11 +455,11 @@ class CSSWarning(UserWarning): Examples -------- >>> df = pd.DataFrame({'A': [1, 1, 1]}) - >>> df.style.applymap(lambda x: 'background-color: blueGreenRed;') - ... .to_excel('styled.xlsx') # doctest: +SKIP + >>> (df.style.applymap(lambda x: 'background-color: blueGreenRed;') + ... .to_excel('styled.xlsx')) # doctest: +SKIP ... # CSSWarning: Unhandled color format: 'blueGreenRed' - >>> df.style.applymap(lambda x: 'border: 1px solid red red;') - ... .to_excel('styled.xlsx') # doctest: +SKIP + >>> (df.style.applymap(lambda x: 'border: 1px solid red red;') + ... .to_excel('styled.xlsx')) # doctest: +SKIP ... # CSSWarning: Too many tokens provided to "border" (expected 1-3) """ @@ -569,7 +569,7 @@ class CategoricalConversionWarning(Warning): >>> from pandas.io.stata import StataReader >>> with StataReader('dta_file', chunksize=2) as reader: # doctest: +SKIP ... for i, block in enumerate(reader): - ... print(i, block)) + ... print(i, block) ... # CategoricalConversionWarning: One or more series with value labels... """ diff --git a/pandas/io/formats/style.py b/pandas/io/formats/style.py index 13aa035e34374..25ba4b697d97b 100644 --- a/pandas/io/formats/style.py +++ b/pandas/io/formats/style.py @@ -961,12 +961,12 @@ def to_latex( Second we will format the display and, since our table is quite wide, will hide the repeated level-0 of the index: - >>> styler.format(subset="Equity", precision=2) + >>> (styler.format(subset="Equity", precision=2) ... .format(subset="Stats", precision=1, thousands=",") ... .format(subset="Rating", formatter=str.upper) ... .format_index(escape="latex", axis=1) ... .format_index(escape="latex", axis=0) - ... .hide(level=0, axis=0) # doctest: +SKIP + ... .hide(level=0, axis=0)) # doctest: +SKIP Note that one of the string entries of the index and column headers is "H&M". Without applying the `escape="latex"` option to the `format_index` method the @@ -982,8 +982,8 @@ def to_latex( ... elif v == "Sell": color = "#ff5933" ... else: color = "#ffdd33" ... return f"color: {color}; font-weight: bold;" - >>> styler.background_gradient(cmap="inferno", subset="Equity", vmin=0, vmax=1) - ... .applymap(rating_color, subset="Rating") # doctest: +SKIP + >>> (styler.background_gradient(cmap="inferno", subset="Equity", vmin=0, vmax=1) + ... .applymap(rating_color, subset="Rating")) # doctest: +SKIP All the above styles will work with HTML (see below) and LaTeX upon conversion: @@ -3503,9 +3503,9 @@ def pipe(self, func: Callable, *args, **kwargs): Since the method returns a ``Styler`` object it can be chained with other methods as if applying the underlying highlighters directly. - >>> df.style.format("{:.1f}") + >>> (df.style.format("{:.1f}") ... .pipe(some_highlights, min_color="green") - ... .highlight_between(left=2, right=5) # doctest: +SKIP + ... .highlight_between(left=2, right=5)) # doctest: +SKIP .. figure:: ../../_static/style/df_pipe_hl2.png diff --git a/pandas/io/formats/style_render.py b/pandas/io/formats/style_render.py index 6ae9c528e4772..41d66ad297da4 100644 --- a/pandas/io/formats/style_render.py +++ b/pandas/io/formats/style_render.py @@ -1076,8 +1076,8 @@ def format( Multiple ``na_rep`` or ``precision`` specifications under the default ``formatter``. - >>> df.style.format(na_rep='MISS', precision=1, subset=[0]) - ... .format(na_rep='PASS', precision=2, subset=[1, 2]) # doctest: +SKIP + >>> (df.style.format(na_rep='MISS', precision=1, subset=[0]) + ... .format(na_rep='PASS', precision=2, subset=[1, 2])) # doctest: +SKIP 0 1 2 0 MISS 1.00 A 1 2.0 PASS 3.00