fahadriazkhan commited on
Commit
560306f
·
verified ·
1 Parent(s): 478d45f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +58 -29
app.py CHANGED
@@ -46,36 +46,36 @@ st.write(f"Your selected hobbies are: {', '.join(hobbies)}")
46
 
47
 
48
  # CSV File Upload and Display
49
- import streamlit as st
50
- import pandas as pd
51
- # import matplotlib.pyplot as plt
52
- import plotly.express as px
53
 
54
- st.title("CSV File Upload and Display")
55
 
56
- # File uploader
57
- uploaded_file = st.file_uploader("Upload a CSV file", type=["csv"])
58
 
59
- if uploaded_file:
60
- # Read the uploaded file
61
- data = pd.read_csv(uploaded_file)
62
 
63
- # Display the data preview
64
- st.write("Data Preview:")
65
- st.dataframe(data)
66
 
67
- # Display data statistics
68
- if uploaded_file:
69
- st.write("Data Statistics:")
70
- st.write(data.describe())
71
 
72
- # Display a line and Bar chart
73
- if uploaded_file:
74
- st.write("Line Chart Example:")
75
- st.line_chart(data)
76
 
77
- st.write("Bar Chart Example:")
78
- st.bar_chart(data)
79
 
80
  # st.write("Custom Matplotlib Chart")
81
 
@@ -85,12 +85,12 @@ if uploaded_file:
85
  # st.pyplot(fig)
86
 
87
  # User selects x and y axes
88
- x_axis = st.selectbox("Choose X-axis:", data.columns)
89
- y_axis = st.selectbox("Choose Y-axis:", data.columns)
90
 
91
- # Generate scatter plot
92
- fig = px.scatter(data, x=x_axis, y=y_axis, title="Scatter Plot")
93
- st.plotly_chart(fig)
94
 
95
 
96
 
@@ -118,4 +118,33 @@ if uploaded_file:
118
  # st.plotly_chart(fig)
119
 
120
 
121
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
46
 
47
 
48
  # CSV File Upload and Display
49
+ # import streamlit as st
50
+ # import pandas as pd
51
+ # # import matplotlib.pyplot as plt
52
+ # import plotly.express as px
53
 
54
+ # st.title("CSV File Upload and Display")
55
 
56
+ # # File uploader
57
+ # uploaded_file = st.file_uploader("Upload a CSV file", type=["csv"])
58
 
59
+ # if uploaded_file:
60
+ # # Read the uploaded file
61
+ # data = pd.read_csv(uploaded_file)
62
 
63
+ # # Display the data preview
64
+ # st.write("Data Preview:")
65
+ # st.dataframe(data)
66
 
67
+ # # Display data statistics
68
+ # if uploaded_file:
69
+ # st.write("Data Statistics:")
70
+ # st.write(data.describe())
71
 
72
+ # # Display a line and Bar chart
73
+ # if uploaded_file:
74
+ # st.write("Line Chart Example:")
75
+ # st.line_chart(data)
76
 
77
+ # st.write("Bar Chart Example:")
78
+ # st.bar_chart(data)
79
 
80
  # st.write("Custom Matplotlib Chart")
81
 
 
85
  # st.pyplot(fig)
86
 
87
  # User selects x and y axes
88
+ # x_axis = st.selectbox("Choose X-axis:", data.columns)
89
+ # y_axis = st.selectbox("Choose Y-axis:", data.columns)
90
 
91
+ # # Generate scatter plot
92
+ # fig = px.scatter(data, x=x_axis, y=y_axis, title="Scatter Plot")
93
+ # st.plotly_chart(fig)
94
 
95
 
96
 
 
118
  # st.plotly_chart(fig)
119
 
120
 
121
+
122
+ import streamlit as st
123
+ import pandas as pd
124
+ import plotly.express as px
125
+
126
+ st.title("Dashboard Example")
127
+
128
+ # File uploader
129
+ uploaded_file = st.file_uploader("Upload CSV for Dashboard", type=["csv"])
130
+
131
+ if uploaded_file:
132
+ data = pd.read_csv(uploaded_file)
133
+ st.sidebar.title("Dashboard Controls")
134
+
135
+ # Sidebar controls
136
+ column = st.sidebar.selectbox("Select column to analyze:", data.columns)
137
+ chart_type = st.sidebar.selectbox("Choose chart type:", ["Bar", "Line", "Scatter"])
138
+
139
+ # Display summary
140
+ st.write("Summary Statistics:")
141
+ st.write(data.describe())
142
+
143
+ # Generate chart
144
+ if chart_type == "Bar":
145
+ st.bar_chart(data[column])
146
+ elif chart_type == "Line":
147
+ st.line_chart(data[column])
148
+ else:
149
+ fig = px.scatter(data, x=data.index, y=column)
150
+ st.plotly_chart(fig)