【发布时间】:2019-01-21 21:20:15
【问题描述】:
我从这篇文章中了解到,我可以链接到 Jupyter Notebook 中的网站: How to create a table with clickable hyperlink in pandas & Jupyter Notebook
因此,我尝试调整代码以创建一个带有本地文件链接的数据框。但是,当我单击下面代码中的超链接时,什么也没有发生。
如何修复下面的代码以使超链接正常工作?
import os
import pandas as pd
data = [dict(name='file1',
filepath='C:/Users/username/Documents/file1.docx'),
dict(name='file2',
filepath='C:/Users/username/Documents/file2.docx')]
df = pd.DataFrame(data)
def make_clickable(url):
name= os.path.basename(url)
return '<a href="file:///{}">{}</a>'.format(url,name)
df.style.format({'filepath': make_clickable})
【问题讨论】:
标签: python python-3.x pandas jupyter-notebook