mwouts / itables

Pandas DataFrames as Interactive DataTables
https://mwouts.github.io/itables/
MIT License
740 stars 55 forks source link

Export itables rendering #88

Closed adrienpacifico closed 1 year ago

adrienpacifico commented 1 year ago

Hi, Is it possible to export itables rendering to an html file? If so, how?

The main application for me would be to integrate it in Reveal.js presentations.

mwouts commented 1 year ago

Hi Adrien, yes you should be able to export your notebook to an html file (with e.g. jupyter nbconvert --to html), and the interactive table will be preserved.

I have not tested the integration with reveal.js but I'd be curious to know if it does work as well. In case it does not work, would you mind sharing a minimal reveal.js notebook with a simple interactive table?

adrienpacifico commented 1 year ago

Hi Marc, Thank you for your answer! What I would have liked is to export only the table such that I can include it in an iframe or something like it. Finding the html section from an nbconvert export would be tedious (open the hml file, find the corresponding portion of code in a possibly long file, copy-paste the corresponding code, etc). What I was seeking was something like df.itable_to_html("my_table.html") (or any other variation), or another way to export just the table. I am not talking about reaveal.js notebook export but vanilla reveal.js. I do not have a minimal example of an interactive table (here is an example with a plotly graph , if just want to put an itable instead ;-) ). Ps: I am on holiday, but if you want you can assign me the issue, I will take more time to describe my issue or to solve it when I come back.

mwouts commented 1 year ago

Oh, I see.

Then you're looking for itables.javascript._datatables_repr_. See for instance how the show function calls it: https://github.com/mwouts/itables/blob/ec388a71f574fa8e1f3cc59108f8a0df1375a077/itables/javascript.py#L336-L339

mwouts commented 1 year ago

FYI the same question appeared in the context of Python Shiny apps at #86

mwouts commented 1 year ago

In the latest release of itables==1.2.0, this is available with:

from itables import to_html_datatable