Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

196
Views
Visualizing dataframes in ipython/jupyter notebook by using javascript

I recently discovered that it's quite easy to inject HTML into Jupiter notebook to visualize python objects. That seems particularly useful to me to write a custom interactive plot for pandas dataframes.

The most basic example is:

from IPython.display import HTML
import pandas as pd
HTML( pd.DataFrame([[1,2],[3,4]]).to_html() )
# prints the html representation of a dataframe

What I am trying to accomplish is something similar to what apache zeppelin implements (https://zeppelin.apache.org/, data visualization), where you can pivot columns interactively to explore the data frame.

The first solution I can think of is writing a function get_html that takes the pandas df as input in a json format and visualizes it via d3, pseudocode:

def get_html(json_data):
    big_html = \
    f"""
    <html>
    <script>
    // inject {json_data} into the js library of your choice
    <script>
    </html>
    """
    return big_html
HTML( get_html(df.to_json(orient="records")) )

This seems suboptimal for a number of reasons, for instance

  1. performance (df are often big)
  2. ease of development (get_html should actually call a custom js library, instead of embedding js that way)

However, I cannot figure out how to make this work better.
An idea could be dumping the df onto a json and then re-reading from the disk, but I don't know how to do it.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!