converting links data from list to series changes the links inside the final series (I don't want it clickable just the data frame to be perfect) [duplicate]

print('http://google.com') outputs a clickable url.

How do I get clickable URLs for pd.DataFrame(['http://google.com', 'http://duckduckgo.com']) ?


If you want to apply URL formatting only to a single column, you can use:

data = [dict(name='Google', url='http://www.google.com'),
        dict(name='Stackoverflow', url='http://stackoverflow.com')]
df = pd.DataFrame(data)

def make_clickable(val):
    # target _blank to open new window
    return '<a target="_blank" href="{}">{}</a>'.format(val, val)

df.style.format({'url': make_clickable})

(PS: Unfortunately, I didn't have enough reputation to post this as a comment to @Abdou's post)


Try using pd.DataFrame.style.format for this:

df = pd.DataFrame(['http://google.com', 'http://duckduckgo.com'])

def make_clickable(val):
    return '<a href="{}">{}</a>'.format(val,val)

df.style.format(make_clickable)

I hope this proves useful.