Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import pandas as pd
|
| 3 |
+
import plotly.express as px
|
| 4 |
+
|
| 5 |
+
# Load the data
|
| 6 |
+
def load_data():
|
| 7 |
+
file_path = 'digital_identity_data.xlsx'
|
| 8 |
+
return pd.read_excel(file_path)
|
| 9 |
+
|
| 10 |
+
data = load_data()
|
| 11 |
+
|
| 12 |
+
# Streamlit app layout
|
| 13 |
+
st.title("Digital Identity Dashboard")
|
| 14 |
+
|
| 15 |
+
# Sidebar filters
|
| 16 |
+
st.sidebar.header("Filter Options")
|
| 17 |
+
country_filter = st.sidebar.multiselect("Select Countries:", options=data["Country"].unique(), default=data["Country"].unique())
|
| 18 |
+
gender_filter = st.sidebar.multiselect("Select Genders:", options=data["Gender"].unique(), default=data["Gender"].unique())
|
| 19 |
+
account_status_filter = st.sidebar.multiselect("Select Account Status:", options=data["Account Status"].unique(), default=data["Account Status"].unique())
|
| 20 |
+
|
| 21 |
+
# Apply filters
|
| 22 |
+
filtered_data = data[
|
| 23 |
+
(data["Country"].isin(country_filter)) &
|
| 24 |
+
(data["Gender"].isin(gender_filter)) &
|
| 25 |
+
(data["Account Status"].isin(account_status_filter))
|
| 26 |
+
]
|
| 27 |
+
|
| 28 |
+
# Display filtered data
|
| 29 |
+
st.subheader("Filtered Data")
|
| 30 |
+
st.dataframe(filtered_data)
|
| 31 |
+
|
| 32 |
+
# Visualization: Number of logins by country
|
| 33 |
+
st.subheader("Number of Logins by Country")
|
| 34 |
+
logins_by_country = filtered_data.groupby("Country")["Number of Logins"].sum().reset_index()
|
| 35 |
+
fig = px.bar(logins_by_country, x="Country", y="Number of Logins", title="Logins by Country", color="Country")
|
| 36 |
+
st.plotly_chart(fig)
|
| 37 |
+
|
| 38 |
+
# Visualization: Session duration by gender
|
| 39 |
+
st.subheader("Average Session Duration by Gender")
|
| 40 |
+
session_duration_by_gender = filtered_data.groupby("Gender")["Session Duration (Minutes)"].mean().reset_index()
|
| 41 |
+
fig2 = px.bar(session_duration_by_gender, x="Gender", y="Session Duration (Minutes)", title="Session Duration by Gender", color="Gender")
|
| 42 |
+
st.plotly_chart(fig2)
|
| 43 |
+
|
| 44 |
+
# Visualization: Data breaches reported
|
| 45 |
+
st.subheader("Data Breaches Reported")
|
| 46 |
+
fig3 = px.pie(filtered_data, names="Country", values="Data Breaches Reported", title="Data Breaches by Country")
|
| 47 |
+
st.plotly_chart(fig3)
|
| 48 |
+
|
| 49 |
+
# Visualization: 2FA usage
|
| 50 |
+
st.subheader("2FA Adoption")
|
| 51 |
+
two_fa_usage = filtered_data["2FA Enabled"].value_counts().reset_index()
|
| 52 |
+
two_fa_usage.columns = ["2FA Enabled", "Count"]
|
| 53 |
+
fig4 = px.pie(two_fa_usage, names="2FA Enabled", values="Count", title="2FA Usage")
|
| 54 |
+
st.plotly_chart(fig4)
|
| 55 |
+
|
| 56 |
+
# Footer
|
| 57 |
+
st.markdown("---")
|
| 58 |
+
st.caption("Digital Identity Dashboard - Built with Streamlit")
|