Skip to content

Commit 862e300

Browse files
authored
Format the index too (#198)
1 parent 6100ee3 commit 862e300

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

docs/pandas_style.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ s.background_gradient(axis=None, cmap="YlOrRd")
5959
We can also choose how the data is formatted:
6060

6161
```{code-cell}
62-
s.format("{:.3f}")
62+
s.format("{:.3f}").format_index("{:.3f}")
6363
```
6464

6565
## Caption

itables/sample_dfs.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,11 @@ def get_pandas_styler():
390390
s = df.style
391391
s.background_gradient(axis=None, cmap="YlOrRd")
392392
s.format("{:.3f}")
393+
try:
394+
s.format_index("{:.3f}")
395+
except AttributeError:
396+
# Python 3.7 AttributeError: 'Styler' object has no attribute 'format_index'
397+
pass
393398

394399
s.set_caption(
395400
"A Pandas Styler object with background colors and tooltips"

tests/test_documentation_notebooks_run.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
except ImportError:
1212
pl = None
1313

14-
pytestmark = pytest.mark.skipif(sys.version_info < (3, 7), reason="Require Python>=3.7")
14+
pytestmark = pytest.mark.skipif(sys.version_info < (3, 8), reason="Require Python>=3.8")
1515

1616

1717
def list_doc_notebooks():

0 commit comments

Comments
 (0)