3

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.

asked Aug 8, 2018 at 9:39
2
  • 3
    to_html works on Dataframe maybe you should try pd.Dataframe(Top_20_suppliers).to_html("index.html") Commented 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. Commented Aug 10, 2018 at 5:45

1 Answer 1

7

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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.