Saturday, November 16, 2024
Google search engine
HomeLanguagesPython | Pandas DataFrame.to_html() method

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.




# 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 :

Name Jitender Rahul
0 Marks 78 77.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 :

Name Jitender Purnima
0 Marks 78 78.9
1 Gender Male Female
Dominic Rubhabha-Wardslaus
Dominic Rubhabha-Wardslaushttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Recent Comments