File tree Expand file tree Collapse file tree 3 files changed +18
-4
lines changed
Expand file tree Collapse file tree 3 files changed +18
-4
lines changed Original file line number Diff line number Diff line change @@ -171,6 +171,7 @@ See [the Pandas Styling docs](https://pandas.pydata.org/pandas-docs/stable/user_
171171:tags: [hide-input]
172172
173173import pandas as pd
174+ from pandas.io.formats.style import Styler
174175
175176np.random.seed(24)
176177df = pd.DataFrame({'A': np.linspace(1, 10, 10)})
@@ -195,8 +196,8 @@ def highlight_max(s):
195196 is_max = s == s.max()
196197 return ['background-color: yellow' if v else '' for v in is_max]
197198
198- df.style .\
199- applymap (color_negative_red).\
199+ Styler(df, uuid="1") .\
200+ map (color_negative_red).\
200201 apply(highlight_max).\
201202 set_table_attributes('style="font-size: 10px"')
202203```
Original file line number Diff line number Diff line change @@ -29,6 +29,8 @@ It also has a `thebe-init` tag which means it will be executed when you initiali
2929# Generate some code that we'll use later on in the page
3030import numpy as np
3131import matplotlib.pyplot as plt
32+
33+ np.random.seed(0)
3234```
3335
3436### Hide inputs
@@ -45,6 +47,7 @@ ax.imshow(square)
4547
4648fig, ax = plt.subplots()
4749ax.imshow(wide)
50+ plt.show()
4851```
4952
5053### Hide outputs
@@ -61,6 +64,7 @@ ax.imshow(square)
6164
6265fig, ax = plt.subplots()
6366ax.imshow(wide)
67+ plt.show()
6468```
6569
6670### Hide markdown
@@ -93,6 +97,7 @@ ax.imshow(square)
9397
9498fig, ax = plt.subplots()
9599ax.imshow(wide)
100+ plt.show()
96101```
97102
98103### Hide the whole cell
@@ -108,6 +113,7 @@ ax.imshow(square)
108113
109114fig, ax = plt.subplots()
110115ax.imshow(wide)
116+ plt.show()
111117```
112118
113119## Enriched outputs
@@ -136,6 +142,7 @@ Styled DataFrames (see [the Pandas Styling docs](https://pandas.pydata.org/panda
136142:tags: [hide-input]
137143
138144import pandas as pd
145+ from pandas.io.formats.style import Styler
139146
140147np.random.seed(24)
141148df = pd.DataFrame({'A': np.linspace(1, 10, 10)})
@@ -160,8 +167,8 @@ def highlight_max(s):
160167 is_max = s == s.max()
161168 return ['background-color: yellow' if v else '' for v in is_max]
162169
163- df.style .\
164- applymap (color_negative_red).\
170+ Styler(df, uuid="1") .\
171+ map (color_negative_red).\
165172 apply(highlight_max).\
166173 set_table_attributes('style="font-size: 10px"')
167174```
Original file line number Diff line number Diff line change @@ -31,6 +31,8 @@ through and see how things look!
3131import numpy as np
3232import matplotlib.pyplot as plt
3333
34+ np.random.seed(0)
35+
3436square = np.random.randn(100, 100)
3537wide = np.random.randn(100, 1000)
3638```
@@ -41,6 +43,7 @@ wide = np.random.randn(100, 1000)
4143## A full-width square figure
4244fig, ax = plt.subplots()
4345ax.imshow(square)
46+ plt.show()
4447```
4548
4649``` {code-cell} ipython3
@@ -49,12 +52,14 @@ ax.imshow(square)
4952## A full-width wide figure
5053fig, ax = plt.subplots()
5154ax.imshow(wide)
55+ plt.show()
5256```
5357
5458``` {code-cell} ipython3
5559# Now here's the same figure at regular width
5660fig, ax = plt.subplots()
5761ax.imshow(wide)
62+ plt.show()
5863```
5964
6065### Markdown
@@ -194,6 +199,7 @@ Let's see what happens
194199## code cell in the margin with output
195200fig, ax = plt.subplots()
196201ax.imshow(wide)
202+ plt.show()
197203```
198204
199205```` {margin}
You can’t perform that action at this time.
0 commit comments