[Python] Streamlit: Calculated Column not working as intended

Discussão em 'Python' iniciado por Stack, Maio 20, 2025.

  1. Stack

    Stack Membro Participativo

    I am working on a dashboard using streamlit. Column 3 is supposed to be column 2 divided by column 1. It works in Power BI correctly: Power BI Screenshot

    But it's not working as intended in streamlit. Streamlit Dashboard Screenshot

    I believe the difference between the 2 is that streamlit creates column 3 in the dataframe on the backend based on the raw numbers in each row, then it displays the sum of those percentages.

    Whereas Power BI creates column 3 based on the displayed values in column 1 and 2.

    Here's my code snippet that creates column 3 in streamlit:

    if "Column 2" in self.df.columns and "Column 1" in self.df.columns:
    Two = to_float(self.df["Column 2"])
    One = to_float(self.df["Column 1"])
    self.df["Column 3"] = Two / One


    How can I modify this so that the streamlit dashboard behaves like Power BI and creates column 3 based on the displayed values?

    Continue reading...

Compartilhe esta Página