Creating a dependency list on streamlit

Hi my name is Stephen, I am currently learning streamlit and i will like to create an emission calculator that will filter through an excel file using a drop list to find emission factors. After finding the emission factor it will match the unit (e.g. Tonnes) selected by the user and enable them to enter an amount to perform the calculation.

I have been able to upload the excel file that will be use to obtain the emission factors but i am struggling to create the drop down list to filter through the data, can any help?

my code does not allow me to select the unique values from the excel table

thank you

code below

import streamlit as st 
import pandas as pd 

st.title("Carbon Emission Calculator Tool")

# Load Excel file
def get_data ():
    path = "Emissions.xlsx"
    return pd.read_excel(path,sheet_name="Sheet1",usecols="A:F")

data = get_data()

scope = data.columns
select_scope = st.selectbox('select scope:',scope)

scope = data.columns
selected_column = st.selectbox("Select Scope",options=scope)
column_values = data[selected_column].unique()

Hi @sf558

Could you share a link to your GitHub repo that contain your app file and an excerpt from the XLSX file as an example. This would allow the community to try out the code and reproduce the error.

Best regards,

Hi @dataprofessor thank you for replying to my message.

link to files

when i try data[“Scope”].unique() it does not select the scope column in the excel file and filter the unique values in there.

if you can help me with

  1. fix the issue to create the drop down list to filter the right emission factor ?

thank you in advance

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.