-
-
Save sany2k8/3db51800c24a43eb9986b2981bebe9df to your computer and use it in GitHub Desktop.
Creates a clickable URL from two fields of the pandas DataFrame
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def create_link(file_name, file_id): | |
return f'http://localhost:port/{file_name}/{file_id}' | |
def make_clickable(val): | |
# target _blank to open new window | |
return '<a target="_blank" href="{}">{}</a>'.format(val, val) | |
data['link'] = data.apply(lambda x: create_link(str(x['file_path']), x['file_id']), axis=1) | |
clickable_table = data.style.format({'link': make_clickable}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment