Spaces:
Sleeping
Sleeping
fschwartzer
commited on
Commit
•
8b09f68
1
Parent(s):
67830d9
Update app.py
Browse files
app.py
CHANGED
@@ -117,14 +117,11 @@ if not filtered_df.empty:
|
|
117 |
# Initialize a variable to store the sum for the current 'Conta'
|
118 |
conta_sum = 0.0
|
119 |
|
120 |
-
#
|
121 |
-
# For simplicity, here we're just taking the first 'Modelo' found for the 'Conta'
|
122 |
modelo = conta_df['Modelo'].iloc[0]
|
123 |
|
124 |
# Iterate over each row in the filtered DataFrame for the current 'Conta'
|
125 |
for _, row in conta_df.iterrows():
|
126 |
-
# Extract the numeric value and add it to the conta_sum
|
127 |
-
# Assuming 'Forecasts' is already processed correctly above
|
128 |
lines = row['Forecasts'].split('\n')
|
129 |
for line in lines[:-1]: # Skip the summary line
|
130 |
if line.strip():
|
@@ -138,7 +135,7 @@ if not filtered_df.empty:
|
|
138 |
# Format the sum as a monetary value
|
139 |
monetary_value = f'R$ {conta_sum:,.2f}'
|
140 |
|
141 |
-
# Append the
|
142 |
data.append({'Conta': conta, 'Modelo': modelo, 'Valor Monetário': monetary_value})
|
143 |
|
144 |
# Convert the list to a DataFrame
|
@@ -147,12 +144,19 @@ if not filtered_df.empty:
|
|
147 |
# Calculate the grand total sum of all 'Conta' values
|
148 |
total_sum = sum(float(row['Valor Monetário'].replace('R$ ', '').replace(',', '')) for row in data)
|
149 |
|
150 |
-
#
|
151 |
total_row = pd.DataFrame({'Conta': ['TOTAL'], 'Modelo': [''], 'Valor Monetário': [f'R$ {total_sum:,.2f}']})
|
152 |
-
|
153 |
-
# Concatenate the "Total" row with the existing table data
|
154 |
table_data = pd.concat([table_data, total_row], ignore_index=True)
|
155 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
156 |
# Display the table
|
157 |
st.table(table_data)
|
158 |
|
|
|
117 |
# Initialize a variable to store the sum for the current 'Conta'
|
118 |
conta_sum = 0.0
|
119 |
|
120 |
+
# Take the first 'Modelo' for simplicity
|
|
|
121 |
modelo = conta_df['Modelo'].iloc[0]
|
122 |
|
123 |
# Iterate over each row in the filtered DataFrame for the current 'Conta'
|
124 |
for _, row in conta_df.iterrows():
|
|
|
|
|
125 |
lines = row['Forecasts'].split('\n')
|
126 |
for line in lines[:-1]: # Skip the summary line
|
127 |
if line.strip():
|
|
|
135 |
# Format the sum as a monetary value
|
136 |
monetary_value = f'R$ {conta_sum:,.2f}'
|
137 |
|
138 |
+
# Append the data to the list
|
139 |
data.append({'Conta': conta, 'Modelo': modelo, 'Valor Monetário': monetary_value})
|
140 |
|
141 |
# Convert the list to a DataFrame
|
|
|
144 |
# Calculate the grand total sum of all 'Conta' values
|
145 |
total_sum = sum(float(row['Valor Monetário'].replace('R$ ', '').replace(',', '')) for row in data)
|
146 |
|
147 |
+
# Append the "Total" row
|
148 |
total_row = pd.DataFrame({'Conta': ['TOTAL'], 'Modelo': [''], 'Valor Monetário': [f'R$ {total_sum:,.2f}']})
|
|
|
|
|
149 |
table_data = pd.concat([table_data, total_row], ignore_index=True)
|
150 |
|
151 |
+
# Calculate and append the rows for "Saúde (12% da RLIT)" and "Educação (25% da RLIT)"
|
152 |
+
saude_value = total_sum * 0.15
|
153 |
+
educacao_value = total_sum * 0.25
|
154 |
+
saude_row = pd.DataFrame({'Conta': ['Saúde (15% da RLIT)'], 'Modelo': [''], 'Valor Monetário': [f'R$ {saude_value:,.2f}']})
|
155 |
+
educacao_row = pd.DataFrame({'Conta': ['Educação (25% da RLIT)'], 'Modelo': [''], 'Valor Monetário': [f'R$ {educacao_value:,.2f}']})
|
156 |
+
|
157 |
+
# Append these rows to the table data
|
158 |
+
table_data = pd.concat([table_data, saude_row, educacao_row], ignore_index=True)
|
159 |
+
|
160 |
# Display the table
|
161 |
st.table(table_data)
|
162 |
|