Shivraj8615 commited on
Commit
eb4f0b0
·
verified ·
1 Parent(s): 7deda7d

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +45 -0
app.py ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import pandas as pd
3
+ import seaborn as sns
4
+ import matplotlib.pyplot as plt
5
+ import numpy as np
6
+
7
+ def main():
8
+ st.title("Excel Column Analysis Dashboard")
9
+
10
+ uploaded_file = st.file_uploader("Upload an Excel file", type=["xls", "xlsx"])
11
+
12
+ if uploaded_file is not None:
13
+ df = pd.read_excel(uploaded_file)
14
+ st.write("Preview of Data:")
15
+ st.write(df.head())
16
+
17
+ numeric_columns = df.select_dtypes(include=[np.number]).columns.tolist()
18
+
19
+ if numeric_columns:
20
+ selected_column = st.selectbox("Select a column for analysis (as named in the Excel file)", numeric_columns)
21
+
22
+ if selected_column:
23
+ data = df[selected_column].dropna()
24
+ std_dev = np.std(data, ddof=1)
25
+
26
+ st.write(f"**Calculated Standard Deviation:** {std_dev:.4f}")
27
+
28
+ fig, axes = plt.subplots(1, 2, figsize=(12, 5))
29
+
30
+ sns.histplot(data, kde=True, ax=axes[0], bins=20, color='blue')
31
+ axes[0].set_title(f"Distribution Plot of {selected_column}")
32
+
33
+ sns.lineplot(x=data.index, y=data, ax=axes[1], label='Data')
34
+ axes[1].axhline(y=np.mean(data), color='r', linestyle='--', label='Mean')
35
+ axes[1].axhline(y=np.mean(data) + std_dev, color='g', linestyle='--', label='+1 Std Dev')
36
+ axes[1].axhline(y=np.mean(data) - std_dev, color='g', linestyle='--', label='-1 Std Dev')
37
+ axes[1].legend()
38
+ axes[1].set_title(f"Standard Deviation Plot of {selected_column}")
39
+
40
+ st.pyplot(fig)
41
+ else:
42
+ st.warning("No numeric columns found in the uploaded file.")
43
+
44
+ if __name__ == "__main__":
45
+ main()