Solucionado (ver solução)
Solucionado
(ver solução)
2
respostas

Não consigo rodar o to_excel() no anaconda jupiter notebook

Quando tendo exportar para xlsx é retonado esse erros.

proxima_turma.to_excel('proxima_turma.xlsx', index = False)

Retorno:

ModuleNotFoundError Traceback (most recent call last) Input In [64], in <cell line: 1>() ----> 1 proxima_turma.to_excel('proxima_turma.xlsx', index = False)

File ~\anaconda3\envs\Pandas_formato_entrada_saida_IO\lib\site-packages\pandas\core\generic.py:2345, in NDFrame.to_excel(self, excel_writer, sheet_name, na_rep, float_format, columns, header, index, index_label, startrow, startcol, engine, merge_cells, encoding, inf_rep, verbose, freeze_panes, storage_options) 2332 from pandas.io.formats.excel import ExcelFormatter 2334 formatter = ExcelFormatter( 2335 df, 2336 na_rep=na_rep, (...) 2343 inf_rep=inf_rep, 2344 ) -> 2345 formatter.write( 2346 excel_writer, 2347 sheet_name=sheet_name, 2348 startrow=startrow, 2349 startcol=startcol, 2350 freeze_panes=freeze_panes, 2351 engine=engine, 2352 storage_options=storage_options, 2353 )

File ~\anaconda3\envs\Pandas_formato_entrada_saida_IO\lib\site-packages\pandas\io\formats\excel.py:888, in ExcelFormatter.write(self, writer, sheet_name, startrow, startcol, freeze_panes, engine, storage_options) 884 need_save = False 885 else: 886 # error: Cannot instantiate abstract class 'ExcelWriter' with abstract 887 # attributes 'engine', 'save', 'supported_extensions' and 'write_cells' --> 888 writer = ExcelWriter( # type: ignore[abstract] 889 writer, engine=engine, storage_options=storage_options 890 ) 891 need_save = True 893 try:

File ~\anaconda3\envs\Pandas_formato_entrada_saida_IO\lib\site-packages\pandas\io\excel_openpyxl.py:49, in OpenpyxlWriter.init(self, path, engine, date_format, datetime_format, mode, storage_options, if_sheet_exists, engine_kwargs, **kwargs) 36 def init( 37 self, 38 path, (...) 47 ): 48 # Use the openpyxl module as the Excel writer. ---> 49 from openpyxl.workbook import Workbook 51 engine_kwargs = combine_kwargs(engine_kwargs, kwargs) 53 super().init( 54 path, 55 mode=mode, (...) 58 engine_kwargs=engine_kwargs, 59 )

ModuleNotFoundError: No module named 'openpyxl'

O que falta para conseguir rodar essa exportação

2 respostas
solução!

Oii Fabio, tudo bem contigo?

Para resolver esse erro, você pode tentar instalar a biblioteca openpyxl. Para instalá-la você pode usar o comando:

!pip install openpyxl

Tenta fazer isso no seu notebook e depois me conta aqui se funcionou :)

Qualquer dúvida estou à disposição. Bons estudos!

Resolvido, funcionou perfeitamente. Obrigado, Millena.

Quer mergulhar em tecnologia e aprendizagem?

Receba a newsletter que o nosso CEO escreve pessoalmente, com insights do mercado de trabalho, ciência e desenvolvimento de software