Jun-05-2022, 05:52 PM
Thanks Axel for observation,
# MODULOS
# pandas (integracao com excel)
# openpyxl (integracao com excel)
# xlrd (nao sei pq)
# twilio (envia sms)
import pandas as pd
# PASSO A PASSO DA SOLUCAO
# ABRIR AS 3 PLANILHAS - ok
lista_meses = ['Janeiro', 'Fevereiro', 'Marco']
for mes in lista_meses:
print(mes)
tabela_vendas = pd.read_excel(f'{mes}.xls')
print(tabela_vendas)
if (tabela_vendas['Vendas'] > 1000).any():
print(f'no mes {mes} o encontrou um vendedor com mais de R$1000,00')
_______________________
"C:\Users\Pichau\PycharmProjects\Analise Bonus Viagem\venv\Scripts\python.exe" "C:/Users/Pichau/PycharmProjects/Analise Bonus Viagem/main.py"
Janeiro
Unnamed: 0 Unnamed: 1
0 Vendedor Vendas
1 Vendedor 1 10005
2 Vendedor 2 250
3 Vendedor 3 300
4 Vendedor 4 22
5 Vendedor 5 258
6 Vendedor 6 5
7 Vendedor 7 555
8 Vendedor 8 457
9 Vendedor 9 44
10 Vendedor 10 335
11 Vendedor 11 888
12 Vendedor 12 6
13 Vendedor 13 333
14 Vendedor 14 887
15 Vendedor 15 998
16 Vendedor 16 987
17 Vendedor 17 658
18 Vendedor 18 156
19 Vendedor 19 325
20 Vendedor 20 545
Traceback (most recent call last):
File "C:\Users\Pichau\PycharmProjects\Analise Bonus Viagem\venv\lib\site-packages\pandas\core\indexes\base.py", line 3621, in get_loc
return self._engine.get_loc(casted_key)
File "pandas\_libs\index.pyx", line 136, in pandas._libs.index.IndexEngine.get_loc
File "pandas\_libs\index.pyx", line 163, in pandas._libs.index.IndexEngine.get_loc
File "pandas\_libs\hashtable_class_helper.pxi", line 5198, in pandas._libs.hashtable.PyObjectHashTable.get_item
File "pandas\_libs\hashtable_class_helper.pxi", line 5206, in pandas._libs.hashtable.PyObjectHashTable.get_item
KeyError: 'Vendas'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\Pichau\PycharmProjects\Analise Bonus Viagem\main.py", line 18, in <module>
if (tabela_vendas['Vendas'] > 1000).any():
File "C:\Users\Pichau\PycharmProjects\Analise Bonus Viagem\venv\lib\site-packages\pandas\core\frame.py", line 3505, in __getitem__
indexer = self.columns.get_loc(key)
File "C:\Users\Pichau\PycharmProjects\Analise Bonus Viagem\venv\lib\site-packages\pandas\core\indexes\base.py", line 3623, in get_loc
raise KeyError(key) from err
KeyError: 'Vendas'
Process finished with exit code 1
# MODULOS
# pandas (integracao com excel)
# openpyxl (integracao com excel)
# xlrd (nao sei pq)
# twilio (envia sms)
import pandas as pd
# PASSO A PASSO DA SOLUCAO
# ABRIR AS 3 PLANILHAS - ok
lista_meses = ['Janeiro', 'Fevereiro', 'Marco']
for mes in lista_meses:
print(mes)
tabela_vendas = pd.read_excel(f'{mes}.xls')
print(tabela_vendas)
if (tabela_vendas['Vendas'] > 1000).any():
print(f'no mes {mes} o encontrou um vendedor com mais de R$1000,00')
_______________________
"C:\Users\Pichau\PycharmProjects\Analise Bonus Viagem\venv\Scripts\python.exe" "C:/Users/Pichau/PycharmProjects/Analise Bonus Viagem/main.py"
Janeiro
Unnamed: 0 Unnamed: 1
0 Vendedor Vendas
1 Vendedor 1 10005
2 Vendedor 2 250
3 Vendedor 3 300
4 Vendedor 4 22
5 Vendedor 5 258
6 Vendedor 6 5
7 Vendedor 7 555
8 Vendedor 8 457
9 Vendedor 9 44
10 Vendedor 10 335
11 Vendedor 11 888
12 Vendedor 12 6
13 Vendedor 13 333
14 Vendedor 14 887
15 Vendedor 15 998
16 Vendedor 16 987
17 Vendedor 17 658
18 Vendedor 18 156
19 Vendedor 19 325
20 Vendedor 20 545
Traceback (most recent call last):
File "C:\Users\Pichau\PycharmProjects\Analise Bonus Viagem\venv\lib\site-packages\pandas\core\indexes\base.py", line 3621, in get_loc
return self._engine.get_loc(casted_key)
File "pandas\_libs\index.pyx", line 136, in pandas._libs.index.IndexEngine.get_loc
File "pandas\_libs\index.pyx", line 163, in pandas._libs.index.IndexEngine.get_loc
File "pandas\_libs\hashtable_class_helper.pxi", line 5198, in pandas._libs.hashtable.PyObjectHashTable.get_item
File "pandas\_libs\hashtable_class_helper.pxi", line 5206, in pandas._libs.hashtable.PyObjectHashTable.get_item
KeyError: 'Vendas'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\Pichau\PycharmProjects\Analise Bonus Viagem\main.py", line 18, in <module>
if (tabela_vendas['Vendas'] > 1000).any():
File "C:\Users\Pichau\PycharmProjects\Analise Bonus Viagem\venv\lib\site-packages\pandas\core\frame.py", line 3505, in __getitem__
indexer = self.columns.get_loc(key)
File "C:\Users\Pichau\PycharmProjects\Analise Bonus Viagem\venv\lib\site-packages\pandas\core\indexes\base.py", line 3623, in get_loc
raise KeyError(key) from err
KeyError: 'Vendas'
Process finished with exit code 1