timvink / mkdocs-table-reader-plugin

MkDocs plugin that enables a markdown tag like {{ read_csv('table.csv') }} to directly insert various table formats into a page
https://timvink.github.io/mkdocs-table-reader-plugin/
MIT License
111 stars 18 forks source link

Fix `DataFrame.applymap has been deprecated` warning #55

Closed trymzet closed 9 months ago

trymzet commented 9 months ago

This is caused by this line in mkdocs_table_reader_plugin/markdown.py.

timvink commented 9 months ago

Thanks for mentioning. I don't want to force users to the lastest version of pandas though..

timvink commented 9 months ago

Related #54

trymzet commented 9 months ago

Understandable, but maybe you can add a version check?

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)
timvink commented 9 months ago

Yeah that's a good solution. Normally I wouldn't worry about these kinds of warnings, but some people run mkdocs using --strict mode

timvink commented 9 months ago

Just released v2.0.2 with this change!

Thanks for pushing this :)