I learned from this post that I can link to a website in a Jupyter Notebook: How to create a table with clickable hyperlink in pandas & Jupyter Notebook
So, I tried to adapt the code to create a dataframe with links to local files. However, when I click on the hyperlinks from the code below, nothing happens.
How do I fix the code below for the hyperlinks to work?
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})