fschwartzer commited on
Commit
527c7ca
1 Parent(s): a755ae5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -0
app.py CHANGED
@@ -7,6 +7,12 @@ import numpy as np
7
  df = pd.read_csv('last_results_5.csv')
8
 
9
  temp_data = pd.read_csv('temp_data(2).csv')
 
 
 
 
 
 
10
 
11
  image1 = 'images/rs_pmpa.PNG'
12
 
@@ -164,6 +170,10 @@ if not filtered_df.empty:
164
  # Append these rows to the table data
165
  table_data = pd.concat([table_data, saude_row, educacao_row], ignore_index=True)
166
 
 
 
 
 
167
  # Display the table
168
  st.table(table_data)
169
 
 
7
  df = pd.read_csv('last_results_5.csv')
8
 
9
  temp_data = pd.read_csv('temp_data(2).csv')
10
+ temp_data['Data_Completa'] = pd.to_datetime(temp_data['Data_Completa'])
11
+ temp_data.sort_values(['Instituição', 'Conta', 'Data_Completa'], inplace=True)
12
+ temp_data['Últimos 12 meses'] = temp_data.groupby(['Instituição', 'Conta'])['Valor'].transform(lambda x: x.rolling(window=12, min_periods=1).sum())
13
+ last_dates = temp_data.groupby(['Instituição', 'Conta'])['Data_Completa'].transform(max)
14
+ last_rows = temp_data[temp_data['Data_Completa'] == last_dates]
15
+ ultimo_ano = last_rows[['Instituição', 'Conta', 'Últimos 12 meses']]
16
 
17
  image1 = 'images/rs_pmpa.PNG'
18
 
 
170
  # Append these rows to the table data
171
  table_data = pd.concat([table_data, saude_row, educacao_row], ignore_index=True)
172
 
173
+ last_df = ultimo_ano[ultimo_ano['Instituição'] == selected_instituicao]
174
+ table_data = pd.merge(table_data, last_df)
175
+
176
+
177
  # Display the table
178
  st.table(table_data)
179