mwouts / itables

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

How to show tables in html? #21

Closed jinchen-hou closed 2 years ago

jinchen-hou commented 3 years ago

Hi,

Thank you for this project! I encountered 2 problems while using itables.

  1. How can I remove the red warning messages?
    2020-12-14 13:24:47,950 [41773] WARNING  itables.downsample:22: [JupyterRequire] showing 24x5 of 24x26 as maxColumns=5. See https://mwouts.github.io/itables/#downsampling
  2. The table did not show when I download jupyter notebook as html, how should I solve that problem?
mwouts commented 3 years ago

Hi @jinchen-hou , Thanks for reporting this!

  1. How can I remove the red warning messages?

Well, you could set maxBytes to zero, either as an argument to the show function, or globally on the itables options, see https://mwouts.github.io/itables/#downsampling But maybe you are looking for a way to keep the downsampling and just don't issue the warning?

  1. The table did not show when I download jupyter notebook as html, how should I solve that problem?

Oh that is indeed a problem! Apparently the HTML file misses the jQuery library. Thank you for reporting this, I'll see how to get this fixed. Screenshot from 2020-12-14 22-44-56

mwouts commented 3 years ago

Hi @jinchen-hou , I was able to fix the issue of the HTML export by downgrading nbconvert to version 5.5. Apparently, when the HTML export is done with nbconvert==6.0.x, the resulting HTML file misses jQuery. Can you confirm whether this fixes the issue for you as well?

jinchen-hou commented 3 years ago

Hi @mwouts,

Thank you so much for answering my questions and looking into that issue! Not sure if I am doing this correctly, but I just downgraded my nbconvert to 5.5 and then used nbconvert to convert my ipynb to html. However it still shows the same as above image -- only column names displayed.

The table I tried has more than 10 columns, would that be the reason why? Please let me know if I missed anything in my steps!

mwouts commented 3 years ago

Hi @jinchen-hou , you're welcome, well you know I am also grateful to you for reporting this! I don't think the issue is related to the number of columns - it is more a matter of having, or not, the datatables.net library in the HTML file. As the next steps, I'd recommend to

  1. Double check that you do have the latest version of itables (version 0.3.0) and make sure that nbconvert is in version 5.x (use jupyter --version)
  2. Do the test with a short notebook like the one above. In particular, the notebook must have this cell (this is the cell that injects the datatables.net library)
    from itables import init_notebook_mode
    init_notebook_mode(all_interactive=True)