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

192
Visualizações
Custom pivot_ui aggregator in python?

Is there a way to create a custom aggregator for pivot_ui in python? I'd like to do weighted averages and hide the details of the computation/field-mappings from users, and only provide meaningful labels in the custom aggregator dropdown. All examples of custom aggregators are in javascript. Is there a way to do it in python/jupyter?

eg. in javascript: ( from view-source:http://horner.github.io/pivottable/examples/montreal_2014.html )

    $(function () {
        var tpl =              $.pivotUtilities.aggregatorTemplates;
        $.get("montreal_2014.csv", function(montreal_2014) {
            $("#output").pivotUI($.csv.toArrays(montreal_2014), {
                aggregators: {
                    "Mean Temp (Celcius)":  
                        function() { return tpl.average()(["Mean Temp (C)"])},

in python:

from pivottablejs import pivot_ui
pivot_ui( df, rows=["day"], aggregators= ?? )

How do I define and pass a javascript function obj in jupyter notebook? could I somehow define it with %%javascript in a different cell and reference in python? or is there some magic in the streamlit.components.v1 that can accomplish this?

thanks

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Looking at the pivottablejs library for Python, it looks like they return an IFrame. You can try components.html form Streamlit

import streamlit as st
import streamlit.components.v1 as components
from pivottablejs import pivot_ui
import pandas as pd


t = pivot_ui(df)

with open(t.src) as t:
    components.html(t.read(), width=900, height=1000, scrolling=True)
about 4 years ago · Juan Pablo Isaza Relatório
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