DIVYANSHI SINGH commited on
Commit ·
e5573b4
1
Parent(s): c9db3e3
Layout Fix: Removed flickering CSS and switched to stable 2x2 grid
Browse files
app.py
CHANGED
|
@@ -34,31 +34,25 @@ st.markdown("""
|
|
| 34 |
}
|
| 35 |
.stMetric {
|
| 36 |
background-color: #1f2937;
|
| 37 |
-
padding:
|
| 38 |
border-radius: 12px;
|
| 39 |
border: 1px solid #374151;
|
| 40 |
-
|
| 41 |
-
}
|
| 42 |
-
.stMetric:hover {
|
| 43 |
-
transform: translateY(-5px);
|
| 44 |
-
border-color: #60a5fa;
|
| 45 |
}
|
| 46 |
h1, h2, h3 {
|
| 47 |
color: #60a5fa;
|
| 48 |
font-family: 'Inter', sans-serif;
|
| 49 |
}
|
| 50 |
-
/* Improve block spacing */
|
| 51 |
.block-container {
|
| 52 |
-
padding
|
| 53 |
-
padding-bottom: 5rem;
|
| 54 |
}
|
| 55 |
-
/*
|
| 56 |
.info-box {
|
| 57 |
background-color: rgba(96, 165, 250, 0.1);
|
| 58 |
-
padding:
|
| 59 |
border-radius: 15px;
|
| 60 |
border-left: 6px solid #60a5fa;
|
| 61 |
-
margin
|
| 62 |
}
|
| 63 |
</style>
|
| 64 |
""", unsafe_allow_html=True)
|
|
@@ -178,13 +172,20 @@ def main():
|
|
| 178 |
</div>
|
| 179 |
""", unsafe_allow_html=True)
|
| 180 |
|
| 181 |
-
# Top Metrics
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 187 |
|
|
|
|
| 188 |
st.markdown("---")
|
| 189 |
|
| 190 |
# Visualization Row 1: Distribution & PCA
|
|
|
|
| 34 |
}
|
| 35 |
.stMetric {
|
| 36 |
background-color: #1f2937;
|
| 37 |
+
padding: 24px;
|
| 38 |
border-radius: 12px;
|
| 39 |
border: 1px solid #374151;
|
| 40 |
+
/* Removed all transforms/transitions to prevent flicker */
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
}
|
| 42 |
h1, h2, h3 {
|
| 43 |
color: #60a5fa;
|
| 44 |
font-family: 'Inter', sans-serif;
|
| 45 |
}
|
|
|
|
| 46 |
.block-container {
|
| 47 |
+
padding: 3rem 5rem 5rem 5rem;
|
|
|
|
| 48 |
}
|
| 49 |
+
/* Simple Info Box without heavy margins */
|
| 50 |
.info-box {
|
| 51 |
background-color: rgba(96, 165, 250, 0.1);
|
| 52 |
+
padding: 20px;
|
| 53 |
border-radius: 15px;
|
| 54 |
border-left: 6px solid #60a5fa;
|
| 55 |
+
margin: 20px 0;
|
| 56 |
}
|
| 57 |
</style>
|
| 58 |
""", unsafe_allow_html=True)
|
|
|
|
| 172 |
</div>
|
| 173 |
""", unsafe_allow_html=True)
|
| 174 |
|
| 175 |
+
# Top Metrics - Split into 2x2 grid for better stability
|
| 176 |
+
m1, m2 = st.columns(2)
|
| 177 |
+
with m1:
|
| 178 |
+
st.metric("Total Customers", f"{len(df_filtered):,}")
|
| 179 |
+
with m2:
|
| 180 |
+
st.metric("Avg. Recency", f"{df_filtered['Recency'].mean():.1f} days")
|
| 181 |
+
|
| 182 |
+
m3, m4 = st.columns(2)
|
| 183 |
+
with m3:
|
| 184 |
+
st.metric("Avg. Frequency", f"{df_filtered['Frequency'].mean():.1f} orders")
|
| 185 |
+
with m4:
|
| 186 |
+
st.metric("Avg. Revenue", f"£{df_filtered['Monetary'].mean():,.2f}")
|
| 187 |
|
| 188 |
+
st.markdown("<br>", unsafe_allow_html=True)
|
| 189 |
st.markdown("---")
|
| 190 |
|
| 191 |
# Visualization Row 1: Distribution & PCA
|