Python | Pandas DataFrame.to_html() method

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.

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.

filter_none

edit
close

play_arrow

link
brightness_4
code

# 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())

chevron_right


Output :

Name Jitender Rahul
0 Marks 78 77.9

Example #2 :



filter_none

edit
close

play_arrow

link
brightness_4
code

# 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())

chevron_right


Output :

Name Jitender Purnima
0 Marks 78 78.9
1 Gender Male Female

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.




My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.