rairo commited on
Commit
ef9b050
·
verified ·
1 Parent(s): 8a6ebbd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +42 -7
app.py CHANGED
@@ -115,7 +115,7 @@ with st.sidebar:
115
  uploaded_file = "bon_marche.csv"
116
  #uploaded_file = "healthcare_dataset.csv"
117
  if tabs =='Chat':
118
- st.header("Brave Retail Chat")
119
  st.write("Get visualizations and analysis from our Gemini powered agent")
120
 
121
  # Read the CSV file
@@ -133,13 +133,48 @@ if tabs =='Chat':
133
 
134
  elif tabs == 'Reports':
135
  df = pd.read_csv(uploaded_file)
136
- st.header("Reports")
137
- prompt = """
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
138
  You are an expert business analyst. Analyze the following data and generate a comprehensive and insightful business report, including appropriate key perfomance indicators and reccomendations.
139
 
140
  data:
141
- """ + str(calculate_kpis(df)) + str(get_pandas_profile(df))
142
 
143
- response = model.generate_content(prompt)
144
- report = response.text
145
- st.markdown(report)
 
 
 
 
 
 
115
  uploaded_file = "bon_marche.csv"
116
  #uploaded_file = "healthcare_dataset.csv"
117
  if tabs =='Chat':
118
+ st.subheader("Brave Retail Chat")
119
  st.write("Get visualizations and analysis from our Gemini powered agent")
120
 
121
  # Read the CSV file
 
133
 
134
  elif tabs == 'Reports':
135
  df = pd.read_csv(uploaded_file)
136
+
137
+
138
+ # Streamlit App
139
+ st.subheader("Reports")
140
+ st.write("Filter by Branch Name or Product to generate report")
141
+
142
+ # Display original
143
+
144
+ # Filtering Interface
145
+ st.write("Filtering Options")
146
+ branch_names = df['Branch_Name'].unique().tolist()
147
+ product_names = df['Description'].unique().tolist()
148
+ selected_branch = st.selectbox('Select Branch Name', ['All'] + branch_names)
149
+ selected_product = st.selectbox('Select Product', ['All'] + product_names)
150
+
151
+ # Button to apply filters
152
+ if st.button('Apply Filters'):
153
+ filtered_df = df.copy()
154
+
155
+ # Apply Branch Name Filter
156
+ if selected_branch!= 'All':
157
+ filtered_df = filtered_df[filtered_df['Branch_Name'] == selected_branch]
158
+
159
+ # Apply Description Filter
160
+ if description_filter:
161
+ filtered_df = filtered_df[filtered_df['Description'] == selected_product]
162
+
163
+ # Display filtered DataFrame
164
+ st.write("Filtered DataFrame")
165
+ with st.expander("Preview"):
166
+ st.write(filtered_df)
167
+ prompt = """
168
  You are an expert business analyst. Analyze the following data and generate a comprehensive and insightful business report, including appropriate key perfomance indicators and reccomendations.
169
 
170
  data:
171
+ """ + str(calculate_kpis(filtered_df)) + str(get_pandas_profile(filtered_df))
172
 
173
+ response = model.generate_content(prompt)
174
+ report = response.text
175
+ st.markdown(report)
176
+ else:
177
+ st.write("Filtered DataFrame")
178
+ st.write("Click 'Apply Filters' to see the filtered data.")
179
+
180
+