Skip to content

Commit

Permalink
TST: Fix for doctest in style_render.py (pandas-dev#42778)
Browse files Browse the repository at this point in the history
* TST: Fix for doctest in style_render.py -> pandas.io.formats.style_render.StylerRenderer.format

* Fixed PEP8 Issues

* Fixed Whitespace & Longline PEP8 issues
  • Loading branch information
aneesh98 authored and feefladder committed Sep 7, 2021
1 parent 7eca75b commit 3a46198
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions pandas/io/formats/style_render.py
Original file line number Diff line number Diff line change
Expand Up @@ -646,21 +646,22 @@ def format(
Using ``na_rep`` and ``precision`` with the default ``formatter``
>>> df = pd.DataFrame([[np.nan, 1.0, 'A'], [2.0, np.nan, 3.0]])
>>> df.style.format(na_rep='MISS', precision=3)
>>> df.style.format(na_rep='MISS', precision=3) # doctest: +SKIP
0 1 2
0 MISS 1.000 A
1 2.000 MISS 3.000
Using a ``formatter`` specification on consistent column dtypes
>>> df.style.format('{:.2f}', na_rep='MISS', subset=[0,1])
>>> df.style.format('{:.2f}', na_rep='MISS', subset=[0,1]) # doctest: +SKIP
0 1 2
0 MISS 1.00 A
1 2.00 MISS 3.000000
Using the default ``formatter`` for unspecified columns
>>> df.style.format({0: '{:.2f}', 1: '£ {:.1f}'}, na_rep='MISS', precision=1)
... # doctest: +SKIP
0 1 2
0 MISS £ 1.0 A
1 2.00 MISS 3.0
Expand All @@ -669,7 +670,7 @@ def format(
``formatter``.
>>> df.style.format(na_rep='MISS', precision=1, subset=[0])
... .format(na_rep='PASS', precision=2, subset=[1, 2])
... .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
Expand All @@ -678,6 +679,7 @@ def format(
>>> func = lambda s: 'STRING' if isinstance(s, str) else 'FLOAT'
>>> df.style.format({0: '{:.1f}', 2: func}, precision=4, na_rep='MISS')
... # doctest: +SKIP
0 1 2
0 MISS 1.0000 STRING
1 2.0 MISS FLOAT
Expand All @@ -688,7 +690,7 @@ def format(
>>> s = df.style.format(
... '<a href="a.com/{0}">{0}</a>', escape="html", na_rep="NA"
... )
>>> s.render()
>>> s.render() # doctest: +SKIP
...
<td .. ><a href="a.com/&lt;div&gt;&lt;/div&gt;">&lt;div&gt;&lt;/div&gt;</a></td>
<td .. ><a href="a.com/&#34;A&amp;B&#34;">&#34;A&amp;B&#34;</a></td>
Expand All @@ -698,7 +700,8 @@ def format(
Using a ``formatter`` with LaTeX ``escape``.
>>> df = pd.DataFrame([["123"], ["~ ^"], ["$%#"]])
>>> s = df.style.format("\\textbf{{{}}}", escape="latex").to_latex()
>>> df.style.format("\\textbf{{{}}}", escape="latex").to_latex()
... # doctest: +SKIP
\begin{tabular}{ll}
{} & {0} \\
0 & \textbf{123} \\
Expand Down

0 comments on commit 3a46198

Please sign in to comment.