Navigating through dataframe records

Hi @MrnRbn , Welcome to the Streamlit Community Forum.

would you like to navigate through each rows of the data frame ?
Here’s a code snippet below. Refer to Streamlit Session State demo apps

import streamlit as st
import pandas as pd  
# initialize list of lists
data = {'col1': [1, 2, 3, 4], 'col2': [300, 400, 500, 600]}  
# Create the pandas DataFrame
df = pd.DataFrame(data) 
# print dataframe.
st.dataframe(df)
# Using Session State for pagination
# from example - https://github.com/streamlit/release-demos/blob/0.84/0.84/demos/pagination.py
if "row" not in st.session_state:
    st.session_state.row = 0

def next_row():
    st.session_state.row += 1

def prev_row():
    st.session_state.row -= 1

col1, col2, _, _ = st.columns([0.1, 0.17, 0.1, 0.63])

if st.session_state.row < len(df.index)-1:
    col2.button(">", on_click=next_row)
else:
    col2.write("") 

if st.session_state.row > 0:
    col1.button("<", on_click=prev_row)
else:
    col1.write("") 

st.write(df.iloc[st.session_state.row])

streamlit-test-2021-12-01-12-12-88

Otherwise, you can also implement the component , Streamlit-AgGrid - an user-interactive table.
Hope this helps.

Best,
Avra

3 Likes