1import string
- 2from importlib.metadata import version
- 3
- 4import numpy as np
- 5import pandas as pd
- 6import streamlit as st
- 7
- 8from st_df_table import st_table
- 9
-10st.set_page_config(layout="wide", page_title="st_df_table.st_table")
-11
-12data = {
-13 "Column A": [1, 2, 3, 4, 5, 6],
-14 "Column B": ["A", "B", "C", "F", "G", "H"],
-15 "Column C": [True, False, True, False, True, False],
-16}
-17
-18df = pd.DataFrame(data)
-19
-20st.title(f"st_df_table.st_table ({version('st_df_table')}) - custom DataFrame display")
-21st.subheader("Default")
-22st_table(df)
-23st.subheader("Align left, head color, head text color, head font weight 'normal'")
-24st_table(
-25 df,
-26 head_align="left",
-27 data_align="left",
-28 head_bg_color="red",
-29 head_color="blue",
-30 head_font_weight="normal",
-31 border_color="red",
-32 border_width=3,
-33 key="left",
-34)
-35st.subheader(
-36 "Align right, data color, data text color, data font weight 'bold', no border, columns not 'sortable', table width"
-37)
-38
-39data = {
-40 "Column A": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
-41 "Column C": [True, False, True, False, True, False, False, True, False, True],
-42 "Column B": ["A", "B", "C", "F", "G", "H", "I", "J", "K", "L"],
-43}
-44
-45df = pd.DataFrame(data)
-46
-47st_table(
-48 df,
-49 head_align="right",
-50 data_align="right",
-51 data_bg_color="green",
-52 data_color="yellow",
-53 data_font_weight="bold",
-54 bordered=False,
-55 sortable=False,
-56 table_width=500,
-57 key="right",
-58)
-59
-60st.subheader("Align left, head color, head text color, head font weight 'normal'")
-61st_table(
-62 df,
-63 head_align="left",
-64 data_align="left",
-65 head_bg_color="red",
-66 head_color="blue",
-67 head_font_weight="normal",
-68 border_color="red",
-69 border_width=3,
-70 font="monospace",
-71 font_size=14,
-72 key="left2",
-73)
-74
-75st.subheader("Pagination")
-76df = pd.DataFrame(
-77 {
-78 "Column A": list(range(1, 101)),
-79 "Column B": np.random.choice(list(string.ascii_uppercase), size=100),
-80 "Column C": np.random.rand(100),
-81 }
-82)
-83
-84st_table(
-85 df,
-86 border_width=4,
-87 border_color="red",
-88 paginated=True,
-89 pagination_size_per_page=7,
-90 pagination_bar_size=4,
-91 pagination_text_color="blue",
-92 pagination_bg_color="yellow",
-93 pagination_border_color="green",
-94 pagination_active_color="yellow",
-95)
-
-
-
-