Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting AttributeError: 'Series' object has no attribute 'to_html'?

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.

like image 370
vaibhav pawar Avatar asked Dec 17 '25 19:12

vaibhav pawar


1 Answers

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')
like image 178
Casivio Avatar answered Dec 19 '25 10:12

Casivio



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!