Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

195
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda