I try Adding image & link to pandas DataFrame is succes. (momosingle.html)
But when I load a row to column . pic and link didn't show. (momosingle2.html)
How to solve this problem?
code:
# Assigning the new list as a new column of the dataframe
def path_to_image_html(path):
return '<img src="'+ path + '"width="150" "">'
def path_to_link_html(path):
return '<a href="'+ path + '">點此購買</a>'
# Rendering the dataframe as HTML table
df.to_html(escape=False, formatters=dict(pimage=path_to_image_html,link=path_to_link_html))
# Rendering the images in the dataframe using the HTML method.
HTML(df.to_html(escape=False,formatters=dict(pimage=path_to_image_html,link=path_to_link_html)))
# Saving the dataframe as a webpage
df.to_html('momosingle.html',escape=False, formatters=dict(pimage=path_to_image_html,link=path_to_link_html))
singledf = df.iloc[[0]]
singledf = singledf.transpose()
# Rendering the dataframe as HTML table
singledf.to_html(escape=False, formatters=dict(pimage=path_to_image_html,link=path_to_link_html))
# Rendering the images in the dataframe using the HTML method.
HTML(singledf.to_html(escape=False,formatters=dict(pimage=path_to_image_html,link=path_to_link_html)))
# Saving the dataframe as a webpage
singledf.to_html('momosingle2.html',escape=False, formatters=dict(pimage=path_to_image_html,link=path_to_link_html))