How to create a table with clickable hyperlink to a local file in pandas & Jupyter Notebook How to create a table with clickable hyperlink to a local file in pandas & Jupyter Notebook pandas pandas

How to create a table with clickable hyperlink to a local file in pandas & Jupyter Notebook


Your browser is actually blocking this. You probably see an error message like "Not allowed to load local resource" in your browser's developer tools (Chrome, Firefox, Safari). Changing this would expose you to serious security risks.

An alternative could be to put the files you want to access in the same working directory as your Jupyter Notebook. For instance, if you add a folder named "Documents" in your working directory, you can then link to the files like this:

http://localhost:8888/notebooks/Documents/file1.docx

Your code would be:

import osimport pandas as pddata = [dict(name='file1',     filepath='Documents/file1.docx'),    dict(name='file2',     filepath='Documents/file2.docx')]df = pd.DataFrame(data)def make_clickable(url):    name= os.path.basename(url)    return '<a href="{}">{}</a>'.format(url,name)df.style.format({'filepath': make_clickable})