Skip to main content

Build Excel-style filter widgets for large pandas DataFrames in Streamlit

Project description

PyPI version

Welcome to the streamlit-excel package!

This package provides a Streamlit component for filtering large pandas DataFrames (e.g., over 100,000 rows) through an intuitive, Excel-like interface. It enables interactive filtering directly within a Streamlit app, allowing users to explore and refine data visually and efficiently.

Designed for simplicity and seamless integration, the component is ideal for data scientists and developers building interactive data visualizations.

Key Features

  • Easy Integration: Initialize the component with a Pandas DataFrame using the Table class and store it in the session state.
  • Flexible Filtering: Use Table.show_filter_widget to render a filter widget for specific columns. The widget can be placed anywhere in the app, including the sidebar.
  • Dynamic Views: Access the filtered DataFrame via the Table.view property.
  • Multiple Tables: Support for multiple tables by creating separate Table instances with unique key parameters.
  • Custom Column Names: Customize display names in the filter widget by passing a dictionary to the mapper parameter when creating the Table instance.

Installation

$ pip install streamlit-excel streamlit pandas

Usage

Below is a simple example demonstrating how to use the streamlit-excel package to create a filterable table in a Streamlit app. In this example, we generate a random dataset with 100,000 rows and 5 columns to showcase the package's scalability.

Save the following code to app.py:

import streamlit as st
import streamlit_excel
import pandas as pd
import numpy as np
import random
from datetime import datetime

if "example_table" not in st.session_state:
    n = 100000
    df = pd.DataFrame({
        "Name": np.random.choice(["Emily Johnson", "Michael Smith", "Lena Corwin", "Talia Vexley", "Kai Renford"], n),
        "City": np.random.choice(["Kyoto", "Cape Town", "Vancouver", "New York City", "Paris"], n),
        "Color": np.random.choice(["Red", "Green", "Yellow", "Blue"], n),
        "Start": [datetime(random.randint(1999, 2022), random.randint(1, 12), random.randint(1, 28)) for _ in range(n)],
        "End": [datetime(random.randint(2023, 2025), random.randint(1, 12), random.randint(1, 28)) for _ in range(n)],
    })
    st.session_state.example_table = streamlit_excel.Table(df, "example_table")

st.session_state.example_table.show_filter_widget("Example Table", ["Name", "City", "Color", "Start", "End"])
st.dataframe(st.session_state.example_table.view)
st.dataframe(st.session_state.example_table.view.describe(include="all"))

Run the app:

$ streamlit run app.py

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-excel-0.0.2.tar.gz (5.3 kB view details)

Uploaded Source

Built Distribution

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

streamlit_excel-0.0.2-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

Details for the file streamlit-excel-0.0.2.tar.gz.

File metadata

  • Download URL: streamlit-excel-0.0.2.tar.gz
  • Upload date:
  • Size: 5.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.8

File hashes

Hashes for streamlit-excel-0.0.2.tar.gz
Algorithm Hash digest
SHA256 5b177d362641574fcf0ea117998edabb6b6426cdce3035bf64861495891eedf9
MD5 2fe0ebf842e267690172bc9a2c0109e7
BLAKE2b-256 5edaa2744a652c6caaac3583b8b90f29af44aa1ab0204e6b4b7ff4400cafd374

See more details on using hashes here.

File details

Details for the file streamlit_excel-0.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for streamlit_excel-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 305079cf8ab95b00810420f6b291ee80288a809c2de5e61163cdd6ad523d090e
MD5 d6431c8a0d5107f5337e2e832908c58a
BLAKE2b-256 251e6827696a60b48e285d596e82dfa7214921da329239482eabfe29eeac135e

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