Skip to main content

This Project is created at 2025 Jan 6th

Project description

Streamlit Pivot Table

This Project is created at 2025 Jan 6th

import streamlit as st
from streamlit_pivottable import streamlit_pivottable
import pandas as pd
import numpy as np

# Set page configuration
st.set_page_config(layout='wide')

# Limit the number of rows
num_rows = 1000000

# Generate sample DataFrame for Pivot Table
df = pd.DataFrame({
    "Category": np.random.choice(
        ["Category A", "Category B", "Category C", "Category D",
         "Category E", "Category F", "Category G", "Category H",
         "Category I", "Category J"], size=num_rows),
    "Region": np.random.choice(
        ["North", "South", "East", "West", "Central", "Northeast",
         "Southeast", "Northwest", "Southwest", "International"], size=num_rows),
    "Priority": np.random.choice(
        ["Very Low", "Low", "Medium Low", "Medium", "Medium High",
         "High", "Very High", "Critical", "Non-Critical", "Undefined"], size=num_rows),
    "Product Type": np.random.choice(
        ["Product A", "Product B", "Product C", "Product D", "Product E",
         "Product F", "Product G", "Product H", "Product I", "Product J"], size=num_rows),
    "Quarter": np.random.choice(
        ["Q1", "Q2", "Q3", "Q4", "Q5", "Q6", "Q7", "Q8", "Q9", "Q10"], size=num_rows),
    "Source": np.random.choice(
        ["Online", "Offline", "In-Store", "Marketplace", "Subscription",
         "Direct Sales", "Wholesale", "Retail", "Auction", "Flash Sale"], size=num_rows),
    "Gender": np.random.choice(
        ["Male", "Female", "Other", "Prefer Not to Say", "Non-Binary",
         "Transgender", "Intersex", "Androgynous", "Genderqueer", "Agender"], size=num_rows),
    "Age Range": np.random.choice(
        ["18-24", "25-34", "35-44", "45-54", "55-64", "65-74",
         "75-84", "85-94", "95+", "Under 18"], size=num_rows),
    "Customer Type": np.random.choice(
        ["New Customer", "Returning Customer", "VIP", "Wholesale Buyer",
         "Gift Buyer", "Seasonal Buyer", "Frequent Shopper", "Rare Shopper",
         "Business Client", "Occasional Buyer"], size=num_rows),
    "Promotion": np.random.choice(
        ["Discounted", "Full Price", "Clearance", "Premium", "Subscription Plan",
         "Limited Offer", "Flash Sale", "Bundle Deal", "Gift Pack", "Exclusive"], size=num_rows),
})

df["Value"] = np.random.uniform(1000000, 999999999, size=num_rows).round(2)


sample_size = 50000  # Adjust this to improve performance
df_sample = df.sample(n=sample_size, random_state=42)
data_2d = [df_sample.columns.tolist()] + df_sample.values.tolist()


default_settings = {
   "rows":[],
   "cols":[],
   "aggregatorName":"Count",
   "vals":[],
   "rendererName":"Table",
   "rowOrder":"",
   "colOrder":"",
   "valueFilter":{},
   "hiddenAttributes":[],
   "hiddenFromAggregators":[],
   "hiddenFromDragDrop":[],
   "menuLimit":500,
   "unusedOrientationCutoff":85
}

# Display Streamlit component Pivot Table
with st.spinner("Loading Pivot Table..."):
    with st.container():
        pivot_table_settings = streamlit_pivottable(
            data=data_2d,
            default_settings=default_settings,
            height=40,
            use_container_width=True,
        )

# Display pivot table configuration
if pivot_table_settings:
    st.write("Pivot Table Configuration:")
    st.json(pivot_table_settings)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

streamlit_pivottable-0.2.0.tar.gz (1.9 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

streamlit_pivottable-0.2.0-py3-none-any.whl (11.9 MB view details)

Uploaded Python 3

File details

Details for the file streamlit_pivottable-0.2.0.tar.gz.

File metadata

  • Download URL: streamlit_pivottable-0.2.0.tar.gz
  • Upload date:
  • Size: 1.9 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.3

File hashes

Hashes for streamlit_pivottable-0.2.0.tar.gz
Algorithm Hash digest
SHA256 ff8404b816cf61bda11625ffdeb547245157e5e4f7e42704cb2ac85e9cdbfec1
MD5 6a9c0cd0f648273fe813c4765eb2f91f
BLAKE2b-256 b29597454783373d881391656726e2ce5c2a25240899b22b37eb6e9c3bbb9a3c

See more details on using hashes here.

File details

Details for the file streamlit_pivottable-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for streamlit_pivottable-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ba8ccc21612d42037d8f677adab07b1569f71809f827484c0cab7e1647beb30b
MD5 1ab459368b6784c905b2bf484a73fdfc
BLAKE2b-256 887edf76c4d9e7c35bb8c3d79d7feb16a330adb6e8453f1a0d3d12941b20eaec

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page