Skip to content

Commit

Permalink
Avoid deprecated applymap warning, closes #55
Browse files Browse the repository at this point in the history
  • Loading branch information
timvink authored Oct 11, 2023
1 parent 781fc82 commit aa376e3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion mkdocs_table_reader_plugin/markdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,13 @@ def convert_to_md_table(df: pd.DataFrame, markdown_kwargs: Dict) -> str:
# Escape any pipe characters, | to \|
# See https://github.com/astanin/python-tabulate/issues/241
df.columns = [replace_unescaped_pipes(c) for c in df.columns]
df = df.applymap(lambda s: replace_unescaped_pipes(s) if isinstance(s, str) else s)

# Avoid deprecated applymap warning on pandas>=2.0
# See https://github.com/timvink/mkdocs-table-reader-plugin/issues/55
if pd.__version__.startswith("2"):
df = df.map(lambda s: replace_unescaped_pipes(s) if isinstance(s, str) else s)
else:
df = df.applymap(lambda s: replace_unescaped_pipes(s) if isinstance(s, str) else s)

if "index" not in markdown_kwargs:
markdown_kwargs["index"] = False
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setup(
name="mkdocs-table-reader-plugin",
version="2.0.1",
version="2.0.2",
description="MkDocs plugin to directly insert tables from files into markdown.",
long_description=long_description,
long_description_content_type="text/markdown",
Expand Down

0 comments on commit aa376e3

Please sign in to comment.