SAVING A PANDAS DATAFRAME AS AN HTML WEB PAGE
Listing B.24 shows the contents of read_html_page.py that illustrates how to read the contents of an HTML Web page from Pandas. Note that this code will only work with Web pages that contain at least one HTML <table> element.
Listing B.24: read_html_page.py
import pandas as pd
emps = pd.read_csv("employees.csv")
print("emps:")
print(emps)
print()
emps['year'] = emps['year'].astype(str)
emps['month'] = emps['month'].astype(str)
# separate column for first name and for last name:
emps['fname'],emps['lname'] = emps['name'].str.
split("-",1).str
# concatenate year and month with a "#" symbol:
emps['hdate1'] = emps['year'].
astype(str)+"#"+emps['month'].astype(str)
# concatenate year and month with a "-" symbol:
emps['hdate2'] = emps[['year','month&apos...