Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Saving a Jupyter notebook as HTML does not save pandas dataframes #7465

Open
ppchaigneau opened this issue May 31, 2018 · 5 comments
Open

Saving a Jupyter notebook as HTML does not save pandas dataframes #7465

ppchaigneau opened this issue May 31, 2018 · 5 comments

Comments

@ppchaigneau
Copy link

When we export a notebook at HTML outside of BeakerX, the dataframe tables are preserved. This makes sharing notebooks with people who do not have any coding experience very easy.

The interactive dataframes are not saved when we export to HTML.

@scottdraves
Copy link
Contributor

scottdraves commented Jun 1, 2018

Thank you, yes I agree. Right now, you can use the publication button make simple web pages (hosted HTML) with the live interactive table widgets. You can share the link with anyone.

For the command line, we have a PR to help:
jupyter/nbconvert#778

Would be cool if just writing HTML would work too.
Haven't looked into what it would take to fix if possible.

@tcombes1
Copy link

tcombes1 commented Jul 25, 2018

Hello, I have been searching around for a solution to this Dataframe rendering issue for exporting as just HTML (not publishing to GIST). It appears the same problem happens with the general ipywidgets as well.

A trick that I dont totally understand worked to get things to render is to export as an HTML, then change the header script calls from:

<script src="https://unpkg.com/jupyter-js-widgets@2.0.*/dist/embed.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.1.10/require.min.js"></script>

to this (which is the standard output html when you "embed Widgets"):

<script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js" integrity="sha256-Ae2Vz/4ePdIu6ZyI/5ZGsYnb+m0JlOmKPjt6XZ9JJkA=" crossorigin="anonymous"></script>
<script src="https://unpkg.com/@jupyter-widgets/html-manager@*/dist/embed-amd.js" crossorigin="anonymous"></script>

Note the change in ordering of the require.min.js and jupyter-related calls from the standard html. This find is based off this:
https://ipywidgets.readthedocs.io/en/latest/migration_guides.html

Not sure if these issues were version related, but it was what pushed things over the edge for me after much toiling around. Now I have tables in html!

@kennethjmyers
Copy link

Thank you @tcombes1 this works perfectly!

@kennethjmyers
Copy link

kennethjmyers commented Aug 1, 2018

After playing with this a bit more, I found that changing this line

<script src="https://unpkg.com/jupyter-js-widgets@2.0.*/dist/embed.js"></script>

to this

<script src="https://unpkg.com/@jupyter-widgets/html-manager@*/dist/embed-amd.js" crossorigin="anonymous"></script>

was enough to get this working. I didn't even need to update the require.js or swap the order. Without it however my error looked like this:

Loading failed for the <script> with source “file:///Users/kmyers/Desktop/@jupyter-widgets/base.js”. 180425_RUX_Sunny_Results_Count_Dashboard-All_Data (1).html:1
Loading failed for the <script> with source “file:///Users/kmyers/Desktop/@jupyter-widgets/output.js”. 180425_RUX_Sunny_Results_Count_Dashboard-All_Data (1).html:1
Loading failed for the <script> with source “file:///Users/kmyers/Desktop/@jupyter-widgets/controls.js”. 180425_RUX_Sunny_Results_Count_Dashboard-All_Data (1).html:1
Loading failed for the <script> with source “https://unpkg.com/@jupyter-widgets/base@1.0.0/dist/index.js”. 180425_RUX_Sunny_Results_Count_Dashboard-All_Data (1).html:1
[Show/hide message details.] Error: Script error for: https://unpkg.com/@jupyter-widgets/base@1.0.0/dist/index.js
http://requirejs.org/docs/errors.html#scripterror require.min.js:8:252
Loading failed for the <script> with source “https://unpkg.com/@jupyter-widgets/output@1.0.0/dist/index.js”. 180425_RUX_Sunny_Results_Count_Dashboard-All_Data (1).html:1
[Show/hide message details.] Error: Script error for: https://unpkg.com/@jupyter-widgets/output@1.0.0/dist/index.js
http://requirejs.org/docs/errors.html#scripterror require.min.js:8:252
Loading failed for the <script> with source “https://unpkg.com/@jupyter-widgets/controls@1.1.0/dist/index.js”. 180425_RUX_Sunny_Results_Count_Dashboard-All_Data (1).html:1
[Show/hide message details.] Error: Script error for: https://unpkg.com/@jupyter-widgets/controls@1.1.0/dist/index.js
http://requirejs.org/docs/errors.html#scripterror require.min.js:8:252
C
https://cdnjs.cloudflare.com/ajax/libs/require.js/2.1.10/require.min.js:8:252
onScriptError
https://cdnjs.cloudflare.com/ajax/libs/require.js/2.1.10/require.min.js:29:514

EDIT: After digging more into this it seems this is more because the changed line allows for embedding widgets in the HTML, I opened an issue for this so that hopefully this can be made the default when saving the widget state.

@vidartf
Copy link

vidartf commented Aug 2, 2018

For that incorrect script link, I'll link to the nbconvert PR that would fix this: jupyter/nbconvert#792

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants