import panel as pn import pandas as pd import plotly.express as px # Enable Panel extensions pn.extension(sizing_mode="stretch_width") # Load data def load_data(): file_path = 'digital_identity_data.xlsx' return pd.read_excel(file_path) data = load_data() # Widgets for filters country_filter = pn.widgets.CheckBoxGroup( name="Select Countries", options=data["Country"].unique().tolist(), value=data["Country"].unique().tolist(), inline=True ) gender_filter = pn.widgets.CheckBoxGroup( name="Select Genders", options=data["Gender"].unique().tolist(), value=data["Gender"].unique().tolist(), inline=True ) status_filter = pn.widgets.CheckBoxGroup( name="Select Account Status", options=data["Account Status"].unique().tolist(), value=data["Account Status"].unique().tolist(), inline=True ) # Filter data function def filter_data(countries, genders, statuses): filtered = data[ (data["Country"].isin(countries)) & (data["Gender"].isin(genders)) & (data["Account Status"].isin(statuses)) ] return filtered # Dashboard plots def update_dashboard(countries, genders, statuses): filtered_data = filter_data(countries, genders, statuses) # Logins by Country logins_by_country = filtered_data.groupby("Country")["Number of Logins"].sum().reset_index() fig1 = px.bar(logins_by_country, x="Country", y="Number of Logins", title="Logins by Country", color="Country") # 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") # Data Breaches by Country fig3 = px.pie(filtered_data, names="Country", values="Data Breaches Reported", title="Data Breaches by Country") # 2FA Usage 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") return pn.Row( pn.Column(pn.pane.Markdown("### Logins by Country"), pn.pane.Plotly(fig1)), pn.Column(pn.pane.Markdown("### Session Duration by Gender"), pn.pane.Plotly(fig2)), pn.Column(pn.pane.Markdown("### Data Breaches by Country"), pn.pane.Plotly(fig3)), pn.Column(pn.pane.Markdown("### 2FA Usage"), pn.pane.Plotly(fig4)) ) # Interactive panel dashboard = pn.bind( update_dashboard, countries=country_filter, genders=gender_filter, statuses=status_filter ) # Layout template = pn.template.BootstrapTemplate( title="Digital Identity Dashboard", sidebar=[country_filter, gender_filter, status_filter], main=[dashboard], header_background="#5A9" ) template.servable()