Python “如何创造一只熊猫”;链接“;(href)风格?

Python “如何创造一只熊猫”;链接“;(href)风格?,python,html,python-3.x,pandas,flask,Python,Html,Python 3.x,Pandas,Flask,从中,我意识到可以在数据帧上创建样式。但是,我想知道是否可以创建链接样式。到目前为止,这是我尝试的: def linkify(data_frame_col): list_words = ['<a href="http://this_is_url_{}">{}</a>'.format(a,a) for a in data_frame_col] return list_words def linkify(数据帧列): 列表字=[''。数据帧中的格式(a,a) 返回单字

从中,我意识到可以在数据帧上创建样式。但是,我想知道是否可以创建链接样式。到目前为止,这是我尝试的:

def linkify(data_frame_col):
 list_words = ['<a href="http://this_is_url_{}">{}</a>'.format(a,a) for a in data_frame_col]
 return list_words
def linkify(数据帧列):
列表字=[''。数据帧中的格式(a,a)
返回单字
问题是,当我将pandas数据帧可视化到flask网站时,我得到了以下样式:

['<a href="http://this_is_url_hi">hi</a>',
 '<a href="http://this_is_url_quick fox brown">quick fox brown</a>',
 '<a href="http://this_is_url_fall apart">fall apart</a>',
 '<a href="http://this_is_url_hi">hi</a>',
 '<a href="http://this_is_url_no">no</a>']
[“”,
'',
'',
'',
'']
而不是链接。你知道如何在熊猫数据框内获得这样的高分辨率荧光屏吗

更新

我的模板如下所示:

view.html:

<!doctype html>
<title>title</title>
<link rel=stylesheet type=text/css href="{{ url_for('static', filename='style.css') }}">
<div class=page>
  <h1>Title</h1>
  {% for table in tables %}
    <h2>{{titles[loop.index]}}</h2>
    {{ table|safe }}
  {% endfor %}
</div>

标题
标题
{对于表%%中的表,%}
{{titles[loop.index]}
{{表|安全}}
{%endfor%}

您可以使用IPython的display.HTML类型

from IPython.display import HTML
import pandas as pd

df = pd.DataFrame(['<a href="http://example.com">example.com</a>'])
HTML(df.to_html(escape=False))
从IPython.display导入HTML
作为pd进口熊猫
df=pd.DataFrame([''))
HTML(df.to_HTML(escape=False))

您的模板是什么样子的?在web应用程序中使用pandas时,请注意线程安全问题:@dim谢谢您的帮助!。。。我更新了问题的状态你如何呈现模板?什么是
表格
?是否包含来自
linkify
的返回值?还是在
表中
?谢谢你的帮助,但我不在Ipython笔记本中!只需使用同样适用于您的df.html,因为浏览器将为您呈现特定列的html代码