Streamlit app disconnects and stops before displaying data

Adding to @andfanilo’s answer, when I have to show large dataframe to user I do something like this,

import pandas as pd
import numpy as np
import streamlit as st
from math import ceil


df = pd.DataFrame({"x": np.arange(1_000_000), "y": np.arange(1_000_000)})

page_size = 1000
page_number = st.number_input(
    label="Page Number",
    min_value=1,
    max_value=ceil(len(df)/page_size),
    step=1,
)
current_start = (page_number-1)*page_size
current_end = page_number*page_size
st.write(df[current_start:current_end])

Hope you find it useful for showing big dataframes! :slight_smile:

1 Like