Skip to content
Related Articles

Related Articles

Save Article
Improve Article
Save Article
Like Article

Python | Pandas DataFrame.to_html() method

  • Last Updated : 17 Sep, 2019

With help of DataFrame.to_html() method, we can get the html format of a dataframe by using DataFrame.to_html() method.

Syntax : DataFrame.to_html()
Return : Return the html format of a dataframe.

 Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.  

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning - Basic Level Course

Example #1 :
In this example we can say that by using DataFrame.to_html() method, we are able to get the html format of a dataframe.






# import DataFrame
import pandas as pd
  
# using DataFrame.to_html() method
gfg = pd.DataFrame({'Name': ['Marks'], 
                    'Jitender': ['78'],
                    'Rahul': ['77.9']})
  
print(gfg.to_html())

Output :

NameJitenderRahul
0Marks7877.9

Example #2 :




# import DataFrame
import pandas as pd
  
# using DataFrame.to_html() method
gfg = pd.DataFrame({'Name': ['Marks', 'Gender'],
                    'Jitender': ['78', 'Male'],
                    'Purnima': ['78.9', 'Female']})
  
print(gfg.to_html())

Output :

NameJitenderPurnima
0Marks7878.9
1GenderMaleFemale



My Personal Notes arrow_drop_up
Recommended Articles
Page :