My code looks something like this where i am trying to make a table of column "Supplier" and "Discount"
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')
what i am doing wrong? please help.
-
3to_html works on Dataframe maybe you should try pd.Dataframe(Top_20_suppliers).to_html("index.html")dimension– dimension2018年08月08日 09:43:16 +00:00Commented Aug 8, 2018 at 9:43
-
Thanks. I did something like this and it works for me. Top_20_suppliers = Top_20_suppliers.reset_index() after resetting index of dataFrame i am able to convert data into html file.vaibhav pawar– vaibhav pawar2018年08月10日 05:45:20 +00:00Commented Aug 10, 2018 at 5:45
1 Answer 1
I just came across this and see that it has not been "answered". As @dimension said, convert to a DataFrame and then .to_html() will will work.
Top_20_suppliers = pd.DataFrame(Top_20_suppliers)
Top_20_suppliers.to_html('index.html')
answered May 12, 2021 at 15:09
Casivio
3631 gold badge7 silver badges17 bronze badges
Sign up to request clarification or add additional context in comments.
Comments
lang-py