亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

“工作簿”對象沒有屬性“add_chart”

“工作簿”對象沒有屬性“add_chart”

哆啦的時光機 2022-07-05 17:42:04
我遇到了這個錯誤:AttributeError: 'Workbook' object has no attribute 'add_chart'運行此代碼時(python 版本 3.7.4):import reimport pandas as pdfrom pandas import ExcelWriterfrom pandas import ExcelFileimport numpy# ... other code here not involved to this part ...df = pd.DataFrame({"city": city_list, "tourist": tourist_list, "month": month_list})writer = pd.ExcelWriter('C:\\Users\\portovenere\\Downloads\\exc.xlsx')workbook = writer.bookchart = workbook.add_chart({'type': 'column'})chart.add_series({    'totals':     '=Sheet1!$A$3:$A$21',    'gap':        2,})add_chart我正在關注的這個pandas xlsx-writer 文檔中解釋了用法。我看到add_chart在XlsxWriter/workbook.py第 228 行定義def add_chart(self, options):        """        Create a chart object.        Args:            options: The chart type and subtype options.        Returns:            Reference to a Chart object.        """我錯過了什么?
查看完整描述

1 回答

?
MM們

TA貢獻1886條經驗 獲得超2個贊

添加這一行

import xlsxwriter

正如本 Q/A中所建議的那樣,并按照評論中的建議進行指定xlsxwriter,解決了這個問題。


查看完整回答
反對 回復 2022-07-05
  • 1 回答
  • 0 關注
  • 638 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號