vgosavi2 commited on
Commit
3d6e51e
·
verified ·
1 Parent(s): c2d8d73

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +19 -18
src/streamlit_app.py CHANGED
@@ -57,6 +57,7 @@ st.write(f"Total records: {df.shape[0]} | Total columns: {df.shape[1]}")
57
  st.dataframe(df.head())
58
 
59
  # Pie Chart 1: Top 10 Crime Types
 
60
  years = sorted(df["year"].dropna().astype(int).unique())
61
 
62
  # Year filter (shorter, above chart)
@@ -82,6 +83,24 @@ top_crimes = (
82
  )
83
  top_crimes["Percentage"] = top_crimes["Count"] / top_crimes["Count"].sum()
84
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
85
  # Plotly donut chart ──
86
  fig = px.pie(
87
  top_crimes,
@@ -107,21 +126,3 @@ fig.update_layout(
107
  )
108
 
109
  st.plotly_chart(fig, use_container_width=True)
110
-
111
- #Key Metrics
112
- st.markdown("### Key Metrics")
113
- col1, col2, col3 = st.columns(3)
114
- col1.metric(
115
- label="Total Incidents",
116
- value=f"{len(filtered):,}"
117
- )
118
- col2.metric(
119
- label="Unique Crime Types",
120
- value=f"{filtered['crm_cd_desc'].nunique():,}"
121
- )
122
- # compute share of the top crime
123
- top_share = top_crimes.iloc[0]["Percentage"]
124
- col3.metric(
125
- label=f"Share of Top Crime ({top_crimes.iloc[0]['Crime Type']})",
126
- value=f"{top_share:.1%}"
127
- )
 
57
  st.dataframe(df.head())
58
 
59
  # Pie Chart 1: Top 10 Crime Types
60
+ st.markdown("<div class='title'><h1> Top 10 Crime Type </h1></div>", unsafe_allow_html=True)
61
  years = sorted(df["year"].dropna().astype(int).unique())
62
 
63
  # Year filter (shorter, above chart)
 
83
  )
84
  top_crimes["Percentage"] = top_crimes["Count"] / top_crimes["Count"].sum()
85
 
86
+ #Key Metrics
87
+ st.markdown("### Key Metrics")
88
+ col1, col2, col3 = st.columns(3)
89
+ col1.metric(
90
+ label="Total Incidents",
91
+ value=f"{len(filtered):,}"
92
+ )
93
+ col2.metric(
94
+ label="Unique Crime Types",
95
+ value=f"{filtered['crm_cd_desc'].nunique():,}"
96
+ )
97
+ # compute share of the top crime
98
+ top_share = top_crimes.iloc[0]["Percentage"]
99
+ col3.metric(
100
+ label=f"Share of Top Crime ({top_crimes.iloc[0]['Crime Type']})",
101
+ value=f"{top_share:.1%}"
102
+ )
103
+
104
  # Plotly donut chart ──
105
  fig = px.pie(
106
  top_crimes,
 
126
  )
127
 
128
  st.plotly_chart(fig, use_container_width=True)