Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

199
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda