![]() |
Help with Integration Pandas excel - Python - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Help with Integration Pandas excel - Python (/thread-37400.html) |
Help with Integration Pandas excel - Python - Gegemendes - Jun-05-2022 I'm fascinated with the programming area and yesterday I started to study Python on Youtube. I started to make a video class, I had some setbacks, but I managed to solve it by searching, but I have this error that I couldn't fix. I would like some help if possible. I thank you very much in advance. each worksheet has two columns (salesperson and $sales), in one of the worksheets, there is a salesperson who has reached a value above one thousand reais. in the exercise, programming line, the idea was to give the RUN, generate the information from the spreadsheets and show which month the award-winning seller has. However, he only plotted the month of January, February and March. RE: Help with Integration Pandas excel - Python - Gegemendes - Jun-05-2022 programation RE: Help with Integration Pandas excel - Python - Axel_Erfurt - Jun-05-2022 Don't post Images, post your code in python tags (the python button) RE: Help with Integration Pandas excel - Python - Gegemendes - Jun-05-2022 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 RE: Help with Integration Pandas excel - Python - Axel_Erfurt - Jun-05-2022 I have to repeat myself, please post your code in python tags (the python button, blue yellow) ![]() RE: Help with Integration Pandas excel - Python - Gegemendes - Jun-05-2022 I'm sorry, because I am new here and in the system, I believe that what you asked me is below _______________________ PROGRAM import pandas as pd 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(): ERROR "C:\Users\Pichau\PycharmProjects\Analise Bonus Viagem\venv\Scripts\python.exe" "C:\Program Files\JetBrains\PyCharm Community Edition 2022.1.2\plugins\python-ce\helpers\pydev\pydevconsole.py" --mode=client --port=50368 import sys; print('Python %s on %s' % (sys.version, sys.platform)) sys.path.extend(['C:\\Users\\Pichau\\PycharmProjects\\Analise Bonus Viagem', 'C:/Users/Pichau/PycharmProjects/Analise Bonus Viagem']) PyDev console: starting. Python 3.9.10 (tags/v3.9.10:f2f3f53, Jan 17 2022, 15:14:21) [MSC v.1929 64 bit (AMD64)] on win32 runfile('C:/Users/Pichau/PycharmProjects/Analise Bonus Viagem/main.py', wdir='C:/Users/Pichau/PycharmProjects/Analise Bonus Viagem') 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\AppData\Local\Programs\Python\Python39\lib\code.py", line 90, in runcode exec(code, self.locals) File "<input>", line 1, in <module> File "C:\Program Files\JetBrains\PyCharm Community Edition 2022.1.2\plugins\python-ce\helpers\pydev\_pydev_bundle\pydev_umd.py", line 198, in runfile pydev_imports.execfile(filename, global_vars, local_vars) # execute the script File "C:\Program Files\JetBrains\PyCharm Community Edition 2022.1.2\plugins\python-ce\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile exec(compile(contents+"\n", file, 'exec'), glob, loc) 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' |