data_filter / app.py
Kiranontimitta's picture
Create app.py
d6f3a04 verified
raw
history blame
1.44 kB
import streamlit as st
import pandas as pd
# Load the data
data = pd.read_csv('Exact_Match_Updated_Authors_Data.csv')
# Display the title
st.title("Data Filter:")
# Sidebar filters with "All" option
country_options = ['All'] + list(data['country'].unique())
selected_country = st.sidebar.selectbox('Select Country', country_options)
# Filter by selected country
if selected_country != 'All':
filtered_data = data[data['country'] == selected_country]
else:
filtered_data = data
# Further filter by university
university_options = ['All'] + list(filtered_data['university'].unique())
selected_university = st.sidebar.selectbox('Select University', university_options)
if selected_university != 'All':
filtered_data = filtered_data[filtered_data['university'] == selected_university]
# Further filter by department
department_options = ['All'] + list(filtered_data['department'].unique())
selected_department = st.sidebar.selectbox('Select Department', department_options)
if selected_department != 'All':
filtered_data = filtered_data[filtered_data['department'] == selected_department]
# Further filter by year
year_options = ['All'] + list(filtered_data['year'].unique())
selected_year = st.sidebar.selectbox('Select Year', year_options)
if selected_year != 'All':
filtered_data = filtered_data[filtered_data['year'] == selected_year]
# Display the filtered data
st.write("Filtered Data", filtered_data)