Skip to content

Commit 73b7aa7

Browse files
committed
Fix: index not shown when polars is not installed
1 parent b1a6017 commit 73b7aa7

File tree

4 files changed

+32
-2
lines changed

4 files changed

+32
-2
lines changed

docs/changelog.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
ITables ChangeLog
22
=================
33

4+
2.4.3 (2025-07-01)
5+
------------------
6+
7+
**Fixed**
8+
- We have fixed an issue with an index not shown when `polars` was not installed ([#415](https://github.com/mwouts/itables/issues/415))
9+
10+
411
2.4.2 (2025-06-11)
512
------------------
613

src/itables/javascript.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ def _evaluate_show_index(df, showIndex) -> bool:
351351
return showIndex
352352
if df is None:
353353
return False
354-
if pl is not None and isinstance(df, pl.DataFrame):
354+
if pl is not pd and isinstance(df, pl.DataFrame):
355355
return False
356356
if isinstance(df, pd.DataFrame):
357357
return df.index.name is not None or not isinstance(df.index, pd.RangeIndex)

src/itables/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
"""ITables' version number"""
22

3-
__version__ = "2.4.2"
3+
__version__ = "2.4.3"

tests/test_javascript.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,29 @@ def test_get_itable_arguments():
4141
}
4242

4343

44+
def test_get_itable_arguments_with_index():
45+
"""
46+
As much as possible we want few arguments for the ITable class
47+
"""
48+
dt_args = get_itable_arguments(
49+
df=pd.DataFrame({"x": [1, 2]}, index=pd.Index(["a", "b"], name="index"))
50+
)
51+
del dt_args["table_html"]
52+
del dt_args["connected"]
53+
assert dt_args == {
54+
"classes": get_compact_classes(opt.classes),
55+
"style": get_compact_style(opt.style),
56+
"data_json": '[["a", 1], ["b", 2]]',
57+
"order": [],
58+
"display_logo_when_loading": opt.display_logo_when_loading,
59+
"warn_on_undocumented_option": opt.warn_on_undocumented_option,
60+
"warn_on_unexpected_option_type": opt.warn_on_unexpected_option_type,
61+
"dt_url": opt.dt_url,
62+
"layout": {k: None for k in opt.layout},
63+
"text_in_header_can_be_selected": True,
64+
}
65+
66+
4467
def test_replace_value(
4568
template="line1\nline2\nline3\n", pattern="line2", value="new line2"
4669
):

0 commit comments

Comments
 (0)