【Python問題】解決python的pandas使用to_excel()函數出現問題

問題描述

使用to_excel()函數報錯爲:got invalid value of type <class ‘xml.etree.ElementTree.Element’>, expected string or Element

原始代碼

import  pandas as pd

test = pd.read_excel('原始數據.xlsx')
print(test)
data.to_excel("修改後數據.xlsx",index=False)

問題解決

在cmd終端或者pycharm的terminal終端執行安裝openpyxl 3.0.0 版本

pip install openpyxl==3.0.0  -i https://pypi.douban.com/simple

原來的版本爲3.0.2,可能是出現了bug。

在這裏插入圖片描述

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章