fschwartzer commited on
Commit
396201a
1 Parent(s): d92dd7b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -6
app.py CHANGED
@@ -117,18 +117,34 @@ tab_df = df[df['Instituição'] == selected_instituicao]
117
  data = []
118
 
119
  ultimo_ano = last_rows[['Instituição', 'Conta', 'Últimos 12 meses']]
 
120
 
121
  with tab1:
122
- for conta in ultimo_ano['Conta'].unique():
123
- # Filter the DataFrame for the current 'Conta'
124
- conta_df = ultimo_ano[ultimo_ano['Conta'] == conta]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
125
 
126
  # Convert the list to a DataFrame
127
- table_data = pd.DataFrame(conta_df)
128
- total_sum = table_data['Últimos 12 meses'].sum()
129
 
130
  labels = table_data['Conta']
131
- sizes = [(i / total_sum) * 100 for i in table_data['Últimos 12 meses']]
132
 
133
  #fig1, ax1 = plt.subplots()
134
  #ax1.pie(sizes, labels=labels, autopct='%1.1f%%',)
 
117
  data = []
118
 
119
  ultimo_ano = last_rows[['Instituição', 'Conta', 'Últimos 12 meses']]
120
+ print(ultimo_ano)
121
 
122
  with tab1:
123
+ for conta in tab_df['Conta'].unique():
124
+ # Filter the DataFrame for the current 'Conta'
125
+ conta_df = tab_df[tab_df['Conta'] == conta]
126
+
127
+ # Iterate over each row in the filtered DataFrame for the current 'Conta'
128
+ for _, row in conta_df.iterrows():
129
+ lines = row['Forecasts'].split('\n')
130
+ for line in lines[:-1]: # Skip the summary line
131
+ if line.strip():
132
+ parts = line.split()
133
+ value = parts[-1]
134
+ try:
135
+ conta_sum += float(value)
136
+ except ValueError:
137
+ print(f"Skipping line unable to convert to float: {line}")
138
+
139
+ # Append the data to the list
140
+ data.append({'Conta': conta, 'Modelo': modelo, 'Próximos 12 meses': conta_sum})
141
 
142
  # Convert the list to a DataFrame
143
+ table_data = pd.DataFrame(data)
144
+ total_sum = table_data['Próximos 12 meses'].sum()
145
 
146
  labels = table_data['Conta']
147
+ sizes = [(i / total_sum) * 100 for i in table_data['Próximos 12 meses']]
148
 
149
  #fig1, ax1 = plt.subplots()
150
  #ax1.pie(sizes, labels=labels, autopct='%1.1f%%',)