Skip to content

Commit 7f80384

Browse files
committed
Merge pull request #11634 from TomAugspurger/styler-fu
CLN: Followup to HTML Formatting
2 parents 020e68b + a2eb3b0 commit 7f80384

File tree

10 files changed

+6918
-6252
lines changed

10 files changed

+6918
-6252
lines changed

ci/requirements_all.txt

+1
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,4 @@ lxml
2020
sqlalchemy
2121
bottleneck
2222
pymysql
23+
Jinja2

doc/make.py

+3
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,14 @@ def clean():
104104

105105
def html():
106106
check_build()
107+
os.system('jupyter nbconvert --to=html --template=basic '
108+
'--output=source/html-styling.html source/html-styling.ipynb')
107109
if os.system('sphinx-build -P -b html -d build/doctrees '
108110
'source build/html'):
109111
raise SystemExit("Building HTML failed.")
110112
try:
111113
# remove stale file
114+
os.system('rm source/html-styling.html')
112115
os.system('cd build; rm -f html/pandas.zip;')
113116
except:
114117
pass

doc/source/html-styling.html

+2,981-3,262
Large diffs are not rendered by default.

doc/source/html-styling.ipynb

+2,999-2,986
Large diffs are not rendered by default.

doc/source/themes/nature_with_gtoc/static/nature.css_t

+13
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,19 @@ td.field-body blockquote {
299299
padding-left: 30px;
300300
}
301301

302+
.rendered_html table {
303+
margin-left: auto;
304+
margin-right: auto;
305+
border-right: 1px solid #cbcbcb;
306+
border-bottom: 1px solid #cbcbcb;
307+
}
308+
309+
.rendered_html td, th {
310+
border-left: 1px solid #cbcbcb;
311+
border-top: 1px solid #cbcbcb;
312+
margin: 0;
313+
padding: 0.5em .75em;
314+
}
302315

303316
/**
304317
* See also

doc/source/whatsnew/v0.17.1.txt

+15-1
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,25 @@ New features
2525
Conditional HTML Formatting
2626
^^^^^^^^^^^^^^^^^^^^^^^^^^^
2727

28-
We've added *experimental* support for conditional HTML formatting,
28+
We've added *experimental* support for conditional HTML formatting:
2929
the visual styling of a DataFrame based on the data.
3030
The styling is accomplished with HTML and CSS.
3131
Acesses the styler class with :attr:`pandas.DataFrame.style`, attribute,
3232
an instance of :class:`~pandas.core.style.Styler` with your data attached.
33+
34+
Here's a quick example:
35+
36+
.. ipython:: python
37+
38+
np.random.seed(123)
39+
df = DataFrame(np.random.randn(10, 5), columns=list('abcde'))
40+
html = df.style.background_gradient(cmap='viridis', low=.5)
41+
42+
We can render the HTML to get the following table.
43+
44+
.. raw:: html
45+
:file: whatsnew_0171_html_table.html
46+
3347
See the :ref:`example notebook <style>` for more.
3448

3549
.. _whatsnew_0171.enhancements:

0 commit comments

Comments
 (0)