I have python code that shows a data frame. How can I link the python code to show it as a table in an HTML webpage and use CSS to edit this table? I am using Vs code.
Here is my python code for creating a dataframe.
import requests
import pandas as pd
from bs4 import BeautifulSoup
url = "https://www.worldometers.info/coronavirus/country/Austria/"
soup = BeautifulSoup(requests.get(url).content, "html.parser")
cases, deaths, recovered = soup.select(".maincounter-number")
active_cases, closed_cases = soup.select(".number-table-main")
active_cases_mild, active_cases_serious, _, _ = soup.select(".number-table")
df = pd.DataFrame(
{
"Coronavirus Cases": [cases.get_text(strip=True)],
"Deaths": [deaths.get_text(strip=True)],
"Recovered": [recovered.get_text(strip=True)],
"Currently infected": [active_cases.get_text(strip=True)],
"Closed cases": [closed_cases.get_text(strip=True)],
"Active cases (mild)": [active_cases_mild.get_text(strip=True)],
"Active cases (serious)": [active_cases_serious.get_text(strip=True)],
}
)
print(df)
You can show the table in simple html code just like that for example:
<!DOCTYPE html>
<html lang="en">
<body>
"Test"
</body>
</html>