Just new to coding, I’m just wondering how to add categorical columns select boxes. Thanks
import streamlit as st
import pandas as pd
st.set_page_config(layout="centered")
@st.cache_data(show_spinner=False)
def load_data():
dataframe = pd.read_csv(file_path)
return dataframe
@st.cache_data(show_spinner=False)
def split_frame(input_df, rows):
df = [input_df.loc[i: i + rows - 1, :] for i in range(0, len(input_df), rows)]
return df
file_path = st.file_uploader("Select a File", type=["csv"])
if file_path:
dataset = load_data()
top_menu = st.columns(3)
pagination = st.container()
bottom_menu = st.columns((4, 1, 1))
with bottom_menu[2]:
batch_size = st.selectbox("Page Size", options=[5, 10])
with bottom_menu[1]:
total_pages = (
int(len(dataset) / batch_size) if int(len(dataset) / batch_size) > 0 else 1
)
current_page = st.number_input(
"Page", min_value=1, max_value=total_pages, step=1
)
with bottom_menu[0]:
st.markdown(f"Page **{current_page}** of **{total_pages}** ")
pages = split_frame(dataset, batch_size)
pagination.dataframe(data=pages[current_page - 1], use_container_width=True)