import pandas as pd
data = {
"country": ["Brazil", "Russia", "India", "China", "South Africa"],
"capital": ["Brasilia", "Moscow", "New Dehli", "Beijing", "Pretoria"],
"area": [8.516, 17.10, 3.286, 9.597, 1.221],
"population": [200.4, 143.5, 1252, 1357, 52.98],
}
df = pd.DataFrame(data)
df
country | capital | area | population | |
---|---|---|---|---|
0 | Brazil | Brasilia | 8.516 | 200.40 |
1 | Russia | Moscow | 17.100 | 143.50 |
2 | India | New Dehli | 3.286 | 1252.00 |
3 | China | Beijing | 9.597 | 1357.00 |
4 | South Africa | Pretoria | 1.221 | 52.98 |
table = df.to_html(index=False)
print(table)
<table border="1" class="dataframe"> <thead> <tr style="text-align: right;"> <th>country</th> <th>capital</th> <th>area</th> <th>population</th> </tr> </thead> <tbody> <tr> <td>Brazil</td> <td>Brasilia</td> <td>8.516</td> <td>200.40</td> </tr> <tr> <td>Russia</td> <td>Moscow</td> <td>17.100</td> <td>143.50</td> </tr> <tr> <td>India</td> <td>New Dehli</td> <td>3.286</td> <td>1252.00</td> </tr> <tr> <td>China</td> <td>Beijing</td> <td>9.597</td> <td>1357.00</td> </tr> <tr> <td>South Africa</td> <td>Pretoria</td> <td>1.221</td> <td>52.98</td> </tr> </tbody> </table>