fschwartzer commited on
Commit
f51907a
1 Parent(s): 944b7eb

Update app.py

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