Python Forum
Help with Integration Pandas excel - Python
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help with Integration Pandas excel - Python
#4
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
Reply


Messages In This Thread
RE: Help with Integration Pandas excel - Python - by Gegemendes - Jun-05-2022, 05:52 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Python and pandas: Aggregate lines form Excel sheet Glyxbringer 12 2,019 Oct-31-2023, 10:21 AM
Last Post: Pedroski55
  Active Directory integration dady 2 538 Oct-13-2023, 04:02 AM
Last Post: deanhystad
  Need Help! Pandas EXCEL PIVOT psb3958 1 978 Nov-13-2022, 10:37 PM
Last Post: deanhystad
  export into excel, how to implement pandas into for-loop deneme2 6 2,568 Sep-01-2022, 05:44 AM
Last Post: deneme2
  Problem in saving .xlsm (excel) file using pandas dataframe in python shantanu97 2 4,402 Aug-29-2021, 12:39 PM
Last Post: snippsat
Photo Integration of apache spark and Kafka on eclipse pyspark aupres 1 3,801 Feb-27-2021, 08:38 AM
Last Post: Serafim
  Tableau Time Series Prediction using Python Integration tobimarsh43 0 1,935 Jul-24-2020, 10:38 AM
Last Post: tobimarsh43
  identical cells in 2 different excel sheets python pandas esso 0 1,665 Jul-19-2020, 07:50 PM
Last Post: esso
  R-PYTHON INTEGRATION RELATED PROBLEM arnab93 0 1,467 Jun-05-2020, 02:07 PM
Last Post: arnab93
  STATA/Python Integration jprender 0 1,870 May-03-2020, 09:38 PM
Last Post: jprender

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020