Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -4,21 +4,54 @@ import pandas as pd
|
|
4 |
import matplotlib.pyplot as plt
|
5 |
import seaborn as sns
|
6 |
|
|
|
|
|
|
|
7 |
|
8 |
-
|
9 |
-
st.
|
10 |
-
uploaded_file = st.file_uploader("Choose a CSV file", type="csv")
|
11 |
|
|
|
12 |
if uploaded_file is not None:
|
13 |
data = pd.read_csv(uploaded_file)
|
14 |
-
|
15 |
-
|
|
|
|
|
|
|
|
|
|
|
16 |
col1, col2 = st.columns(2)
|
|
|
17 |
with col1:
|
18 |
-
|
19 |
-
|
|
|
|
|
|
|
|
|
|
|
20 |
st.pyplot(fig1)
|
|
|
21 |
with col2:
|
22 |
-
|
23 |
-
|
24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
import matplotlib.pyplot as plt
|
5 |
import seaborn as sns
|
6 |
|
7 |
+
# App Title with Emojis
|
8 |
+
st.title("๐ **Welcome to the Insane File Uploader** ๐")
|
9 |
+
st.subheader("Upload a CSV file to visualize magic ๐ฎ")
|
10 |
|
11 |
+
# File Uploader
|
12 |
+
uploaded_file = st.file_uploader("Choose a CSV file to start:", type="csv")
|
|
|
13 |
|
14 |
+
# If a file is uploaded
|
15 |
if uploaded_file is not None:
|
16 |
data = pd.read_csv(uploaded_file)
|
17 |
+
|
18 |
+
# Display DataFrame with color
|
19 |
+
st.subheader("๐ฏ Here's your DataFrame ๐ฏ")
|
20 |
+
st.dataframe(data.style.highlight_max(axis=0, color='lightgreen')) # Highlight max values
|
21 |
+
|
22 |
+
# Create two columns for visuals
|
23 |
+
st.subheader("๐ **Data Visualizations**")
|
24 |
col1, col2 = st.columns(2)
|
25 |
+
|
26 |
with col1:
|
27 |
+
st.markdown("### ๐ฅ **Scatter Plot: Salary vs Age**")
|
28 |
+
fig1 = plt.figure(figsize=(7, 5))
|
29 |
+
sns.scatterplot(data=data, x='EstimatedSalary', y='Age', hue="Purchased", palette='coolwarm', s=100)
|
30 |
+
plt.title("Estimated Salary vs Age", fontsize=14, fontweight='bold')
|
31 |
+
plt.xlabel("Estimated Salary", fontsize=12)
|
32 |
+
plt.ylabel("Age", fontsize=12)
|
33 |
+
plt.grid(True)
|
34 |
st.pyplot(fig1)
|
35 |
+
|
36 |
with col2:
|
37 |
+
st.markdown("### ๐จ **Age Distribution**")
|
38 |
+
fig2 = plt.figure(figsize=(7, 5))
|
39 |
+
sns.histplot(data=data, x='Age', kde=True, color='purple', edgecolor='black')
|
40 |
+
plt.title("Age Distribution", fontsize=14, fontweight='bold')
|
41 |
+
plt.xlabel("Age", fontsize=12)
|
42 |
+
plt.ylabel("Frequency", fontsize=12)
|
43 |
+
plt.grid(True)
|
44 |
+
st.pyplot(fig2)
|
45 |
+
|
46 |
+
# Additional interactive feedback
|
47 |
+
st.balloons() # Fun balloons effect when file is uploaded
|
48 |
+
st.success("โ
**Data successfully loaded and visualized!**")
|
49 |
+
|
50 |
+
# Footer section for fun
|
51 |
+
st.markdown("---")
|
52 |
+
st.markdown("๐ก *Powered by Streamlit & Seaborn | Stay Curious & Visualize Everything!* ๐ง ")
|
53 |
+
else:
|
54 |
+
# Fun message if no file is uploaded yet
|
55 |
+
st.markdown("### โฌ๏ธ **Upload a file to get started!**")
|
56 |
+
st.info("Hint: Make sure your CSV has columns like **EstimatedSalary, Age, and Purchased** for best results!")
|
57 |
+
|