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

191
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
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