简体   繁体   中英

Pandas export data to Excel file (hyperlink)

I have a pandas dataframe and would like to export the data to an Excel file. The dataframe contains only two columns, one is for the date, and the other are links in text format. May I ask are there any python functions or codes for parsing the link text in the whole column into hyperlink so others can just one click the link in the excel file and would be able to access the website? Thank you very much.

TWO WAY TO SOLVE:

df["short_link"] = df["short_link"].map(lambda short_link: '=HYPERLINK("{}","{}")'.format(short_link,short_link))

2.this isn't tested. Note me if it doesn't work.

df["title"] = '=HYPERLINK("'+df["short_link"]+'","'+df["short_link"]+'")'

This may help u.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM