79430847

Date: 2025-02-11 17:32:01
Score: 3
Natty:
Report link

Firstly, according to the st.dataframe documentation, st.dataframe does not return a dataframe but a dataframe placeholder unless you specify an 'on_select' event. The most effective usage of st.dataframe's return value is to get the event data from the displayed dataframe.

Here is an example, taken from the documentation, on how to use the return value of st.dataframe:

import streamlit as st
import pandas as pd
import numpy as np

if "df" not in st.session_state:
    st.session_state.df = pd.DataFrame(
        np.random.randn(12, 5), columns=["a", "b", "c", "d", "e"]
    )

event = st.dataframe(
    st.session_state.df,
    key="data",
    on_select="rerun",
    selection_mode=["multi-row", "multi-column"],
)

event.selection

Secondly, I see that you're not manipulating the original dataframe 'df' - maybe it would be more help if you explain what are you trying to accomplish with 'ddd2'?

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Ends in question mark (2):
  • Looks like a comment (1):
  • Low reputation (1):
Posted by: user29434717