【发布时间】:2019-01-15 12:35:27
【问题描述】:
我的代码看起来像这样,我正在尝试制作一个包含“供应商”和“折扣”列的表格
Discount_By_Suppliers = data.groupby(["Supplier"])["Discount"].sum()
Top_20_suppliers = Discount_By_Suppliers.nlargest(25)
print(Top_20_suppliers)
Top_20_suppliers.to_html('index.html')
我做错了什么?请帮忙。
【问题讨论】:
-
to_html 适用于 Dataframe 也许你应该尝试 pd.Dataframe(Top_20_suppliers).to_html("index.html")
-
谢谢。我做了这样的事情,它对我有用。 Top_20_suppliers = Top_20_suppliers.reset_index() 重置dataFrame的索引后,我可以将数据转换为html文件。
标签: python html-table