Pandas style has no effect
jurij-ch opened this issue Β· comments
π Bug
Running in Jupyter Lab (Version 4.0.11) the cell with code like this
my_df.style.applymap(lambda x: f"background-color: pink")
I get the table in output with pink cell. But running the same input notebook with Papermill there is no any style effect. See picture attached. Thank you in advance!
Looks like this is due to a limitation regarding CSS. The CSS styling requires the interactive mode since papermill runs notebook in non-interactive.
Any workarounds?
There used to be a prompt in JupyterLab to mark the notebook as trusted when it loaded a papermill executed ipynb for exactly that. Try checking if there's a file menu item to "Trust Notebook" and it should appear.
@MSeal , thank you, I tried the approach you suggested, but it did not help in my case.
But I found the way how make things working and it was tested in win and linux (via docker) environments. The idea is to use jupyter nbconvert instead of papermill. The convertion I do in two steps (maybe soon will try to rewrite into single one):
jupyter nbconvert --to notebook --execute --output nb_OUT.ipynb nb.ipynb
jupyter nbconvert nb_OUT.ipynb --no-input --to html
Thus, we trigger the notebook running, and when it saved we convert it to HTML. With that all the formatting of DataFrame and markdown output was preserved.