YchKhan's picture
Create app.py
70d9c5a verified
import streamlit as st
import pandas as pd
import plotly.express as px
# Load the data
def load_data():
file_path = 'digital_identity_data.xlsx'
return pd.read_excel(file_path)
data = load_data()
# Streamlit app layout
st.title("Digital Identity Dashboard")
# Sidebar filters
st.sidebar.header("Filter Options")
country_filter = st.sidebar.multiselect("Select Countries:", options=data["Country"].unique(), default=data["Country"].unique())
gender_filter = st.sidebar.multiselect("Select Genders:", options=data["Gender"].unique(), default=data["Gender"].unique())
account_status_filter = st.sidebar.multiselect("Select Account Status:", options=data["Account Status"].unique(), default=data["Account Status"].unique())
# Apply filters
filtered_data = data[
(data["Country"].isin(country_filter)) &
(data["Gender"].isin(gender_filter)) &
(data["Account Status"].isin(account_status_filter))
]
# Display filtered data
st.subheader("Filtered Data")
st.dataframe(filtered_data)
# Visualization: Number of logins by country
st.subheader("Number of Logins by Country")
logins_by_country = filtered_data.groupby("Country")["Number of Logins"].sum().reset_index()
fig = px.bar(logins_by_country, x="Country", y="Number of Logins", title="Logins by Country", color="Country")
st.plotly_chart(fig)
# Visualization: Session duration by gender
st.subheader("Average Session Duration by Gender")
session_duration_by_gender = filtered_data.groupby("Gender")["Session Duration (Minutes)"].mean().reset_index()
fig2 = px.bar(session_duration_by_gender, x="Gender", y="Session Duration (Minutes)", title="Session Duration by Gender", color="Gender")
st.plotly_chart(fig2)
# Visualization: Data breaches reported
st.subheader("Data Breaches Reported")
fig3 = px.pie(filtered_data, names="Country", values="Data Breaches Reported", title="Data Breaches by Country")
st.plotly_chart(fig3)
# Visualization: 2FA usage
st.subheader("2FA Adoption")
two_fa_usage = filtered_data["2FA Enabled"].value_counts().reset_index()
two_fa_usage.columns = ["2FA Enabled", "Count"]
fig4 = px.pie(two_fa_usage, names="2FA Enabled", values="Count", title="2FA Usage")
st.plotly_chart(fig4)
# Footer
st.markdown("---")
st.caption("Digital Identity Dashboard - Built with Streamlit")