Is there a way to incorporate pivottablejs in streamlit

It’s a little awkward because the pivot table dynamically resizes, but this works on my computer

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

iris = pd.read_csv(
    "https://raw.githubusercontent.com/mwaskom/seaborn-data/master/iris.csv"
)

t = pivot_ui(iris)

with open(t.src) as t:
    components.html(t.read(), width=900, height=1000, scrolling=True)

It wouldn’t be much to either add this to the pivottablejs Python package, or create a static Component for this.

4 Likes