Search code examples
pythonjupyter-notebookgist

How to make pandas' dataframes side by side on gist


I am triying to make pandas dataFrames side by side on gist. In Jupyter side everything looks fine. When I embed the notebook to gist, layout is destroyed. You can see it from link below. https://gist.github.com/cagriemreakin/2e214e1bf81a9768293e31051b5d5644

I used the code below to make dframes side by side on notebook.

from IPython.display import Image, display,HTML
CSS = """

div.cell:nth-child(5).output {
    flex-direction: row;
}
"""

HTML('<style>{}</style>'.format(CSS))

So, what should I do for gist side? Thanks


Solution

  • I'm pretty sure that what the gist is doing is just nicely displaying the .ipynb file, which is just a bunch of JSON. So it isn't actually running your code and thus the css modification code won't run on gist. It can only display the code and results stored in the .ipynb file according to the default css.

    An alternative is to try nbviewer and follow the instructions detailed here that run through how to display custom css for your notebook using Gitub and nbviewer.