Created
March 29, 2019 10:34
-
-
Save elena-roff/bd48cf59dcfda900190c808bc89cfd38 to your computer and use it in GitHub Desktop.
Creates a clickable URL from two fields of the pandas DataFrame
This file contains 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