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

188
Views
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 answers
Answer question

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 Report
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!