Pandas - Writing an excel file containing unicode - IllegalCharacterError

后端 未结 7 1356
离开以前
离开以前 2021-02-07 17:05

I have the following code:

import pandas as pd

x = [u\'string with some unicode: \\x16\']
df = pd.DataFrame(x)

If I try to write this datafram

7条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-02-07 18:09

    for writing a data frame containing unicode characters to multiple sheets in a single excel file below code can be helpful:

    %pip install xlsxwriter
    from pandas import ExcelWriter
    import xlsxwriter
    writer = ExcelWriter('notes.xlsx')
    for key in dict_df:
            data[key].to_excel(writer, key,index=False,engine='xlsxwriter')
    writer.save()
    

提交回复
热议问题