/usr/local/lib/python3.10/dist-packages/pandas/io/common.py in gethandle(pathorbuf,…
- User
/usr/local/lib/python3.10/dist-packages/pandas/io/common.py in get_handle(path_or_buf, mode, encoding, compression, memory_map, is_text, errors, storage_options) 854 if ioargs.encoding and "b" not in ioargs.mode: 855 # Encoding --> 856 handle = open( 857 handle, 858 ioargs.mode,
FileNotFoundError: [Errno 2] No such file or directory: 'Airlines - TREINO.csv'
- Assistant
It seems that the file 'Airlines - TREINO.csv' does not exist in the specified path. Please ensure that the file is located in the correct directory and that the file name is spelled correctly.
- User
oi
- Assistant
Olá! Como posso ajudar você hoje?
- User
drive.mount('/content/drive', force_remount=True) csv_path='/content/drive/MyDrive/DESPESAS_MEDICAS_TREINO.xls' base = pd.read_xls(xls_path, encoding='ISO-8859-1', sep=';') print(base)
- Assistant
Olá! Parece que você está tentando montar o Google Drive e ler um arquivo .xls usando o pandas. Aqui está um exemplo de como fazer isso:
from google.colab import drive import pandas as pd # Montando o Google Drive drive.mount('/content/drive', force_remount=True) # Caminho para o arquivo .xls xls_path = '/content/drive/MyDrive/DESPESAS_MEDICAS_TREINO.xls' # Lendo o arquivo .xls com pandas base = pd.read_excel(xls_path, encoding='ISO-8859-1', sep=';') # Exibindo os dados do arquivo print(base)Certifique-se de fornecer o caminho correto para o arquivo DESPESAS_MEDICAS_TREINO.xls na linha
xls_path. Além disso, alterei o métodoread_xlspararead_excelpara melhor compatibilidade com a leitura de arquivos .xls.Espero que isso ajude!
- User
TypeError: read_excel() got an unexpected keyword argument 'encoding'
- Assistant
Peço desculpas pelo erro. Se você está lendo um arquivo .xls, não é necessário especificar o parâmetro 'encoding' ao usar o método
read_excel()do pandas. Aqui está o código corrigido:from google.colab import drive import pandas as pd # Montando o Google Drive drive.mount('/content/drive', force_remount=True) # Caminho para o arquivo .xls xls_path = '/content/drive/MyDrive/DESPESAS_MEDICAS_TREINO.xls' # Lendo o arquivo .xls com pandas base = pd.read_excel(xls_path, sep=';') # Exibindo os dados do arquivo print(base)Certifique-se de fornecer o caminho correto para o arquivo DESPESAS_MEDICAS_TREINO.xls na linha
xls_path.Desculpe novamente pelo engano e espero que agora funcione corretamente!