add hyperlink to excel sheet created by pandas dataframe to_excel method

后端 未结 5 1603
栀梦
栀梦 2020-12-15 11:56

I have converted a pandas DataFrame to an Excel sheet using df.to_excel.

Now, I want to add hyperlinks to the values in one column. In other words, when a customer

5条回答
  •  南笙
    南笙 (楼主)
    2020-12-15 11:58

    You can use:

    df = pd.DataFrame(list(range(5)), columns=['a'])
    
    df['a'] = df['a'].apply(lambda x: 'link'.format(x))
    
    HTML(df.to_html(escape=False))
    

提交回复
热议问题