Skip to content

Commit aa376e3

Browse files
authored
Avoid deprecated applymap warning, closes #55
1 parent 781fc82 commit aa376e3

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

mkdocs_table_reader_plugin/markdown.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,13 @@ def convert_to_md_table(df: pd.DataFrame, markdown_kwargs: Dict) -> str:
2525
# Escape any pipe characters, | to \|
2626
# See https://github.com/astanin/python-tabulate/issues/241
2727
df.columns = [replace_unescaped_pipes(c) for c in df.columns]
28-
df = df.applymap(lambda s: replace_unescaped_pipes(s) if isinstance(s, str) else s)
28+
29+
# Avoid deprecated applymap warning on pandas>=2.0
30+
# See https://github.com/timvink/mkdocs-table-reader-plugin/issues/55
31+
if pd.__version__.startswith("2"):
32+
df = df.map(lambda s: replace_unescaped_pipes(s) if isinstance(s, str) else s)
33+
else:
34+
df = df.applymap(lambda s: replace_unescaped_pipes(s) if isinstance(s, str) else s)
2935

3036
if "index" not in markdown_kwargs:
3137
markdown_kwargs["index"] = False

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
setup(
77
name="mkdocs-table-reader-plugin",
8-
version="2.0.1",
8+
version="2.0.2",
99
description="MkDocs plugin to directly insert tables from files into markdown.",
1010
long_description=long_description,
1111
long_description_content_type="text/markdown",

0 commit comments

Comments
 (0)