添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

I am trying to save the content of pandas dataframe to excel file in windows/azure databricks. import pandas as pd

Create a Pandas dataframe from the data.

df = pd.DataFrame({'Data': [10, 20, 30, 20, 15, 30, 45]})

Create a Pandas Excel writer using XlsxWriter as the engine.

writer = pd.ExcelWriter('pandas_simple.xlsx', engine='xlsxwriter')

Convert the dataframe to an XlsxWriter Excel object.

df.to_excel(writer, sheet_name='Sheet1')

Close the Pandas Excel writer and output the Excel file.

writer.save()

Error >>

ModuleNotFoundError: No module named 'xlsxwriter'

at line #2 pd.ExcelWriter()

databricks cluster is running on spark 2.4.4 Any suggestion on how to fix this ?

I changed the engine from "xlsxwtier" to "openpyxl" the error is gone. But gives me " PermissionError: [Errno 13] Permission denied: 'pandas_simple.xlsx'" on the save() sophia Jul 2, 2020 at 16:52 df = pd.DataFrame({'Data': [10, 20, 30, 20, 15, 30, 45]}) writer = pd.ExcelWriter('pandas_simple.xlsx', engine='xlsxwriter') df.to_excel(writer, sheet_name='Sheet1') writer.save()
enginestr (optional)

Engine to use for writing. If None, defaults to io.excel..writer. NOTE: can only be passed as a keyword argument.

Deprecated since version 1.2.0: As the xlwt package is no longer maintained, the xlwt engine will be removed in a future version of pandas.

https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.ExcelWriter.html

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.