nteract / papermill

📚 Parameterize, execute, and analyze notebooks
http://papermill.readthedocs.io/en/latest/
BSD 3-Clause "New" or "Revised" License
5.99k stars 428 forks source link

Pandas style has no effect #773

Closed jurij-ch closed 9 months ago

jurij-ch commented 9 months ago

🐛 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!

papermill-style

jurij-ch commented 9 months ago

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?

MSeal commented 9 months ago

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.

jurij-ch commented 9 months ago

@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.