fschwartzer commited on
Commit
78b5466
1 Parent(s): bfd81f2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -1
app.py CHANGED
@@ -45,7 +45,6 @@ with st.sidebar:
45
  # Filter the DataFrame based on selected values
46
  filtered_df = df[(df['Instituição'] == selected_instituicao) & (df['Conta'] == selected_conta)]
47
 
48
-
49
  # Set custom width for columns
50
  col1_width = 400
51
  col2_width = 400
@@ -99,3 +98,36 @@ if not filtered_df.empty:
99
 
100
  else:
101
  col2.warning('No data available for the selected filters.')
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45
  # Filter the DataFrame based on selected values
46
  filtered_df = df[(df['Instituição'] == selected_instituicao) & (df['Conta'] == selected_conta)]
47
 
 
48
  # Set custom width for columns
49
  col1_width = 400
50
  col2_width = 400
 
98
 
99
  else:
100
  col2.warning('No data available for the selected filters.')
101
+
102
+ # Create a table in the third column
103
+ col3 = st.column()
104
+ col3.header('Tabela com previsões')
105
+
106
+ if not filtered_df.empty:
107
+ data_string = filtered_df['Forecasts'].iloc[0]
108
+
109
+ # Create a list to store data for each period
110
+ data = []
111
+
112
+ # Split the string into lines
113
+ lines = data_string.split('\n')
114
+
115
+ # Iterate through the lines and extract the values
116
+ for line in lines[:-2]:
117
+ period, value = line.split()
118
+ num_float = float(value)
119
+ monetary_value = f'R$ {num_float:,.2f}' # Adding commas for thousands separator
120
+ data.append({'Período': int(period), 'Valor Monetário': monetary_value})
121
+
122
+ # Create a DataFrame from the list
123
+ table_data = pd.DataFrame(data)
124
+
125
+ # Add a row for the sum
126
+ total_sum = table_data['Valor Monetário'].str.replace('R$ ', '').str.replace(',', '').astype(float).sum()
127
+ table_data = table_data.append({'Período': 'Total', 'Valor Monetário': f'R$ {total_sum:,.2f}'}, ignore_index=True)
128
+
129
+ # Display the table
130
+ col3.table(table_data)
131
+
132
+ else:
133
+ col3.warning('No data available for the selected filters.')