如何使用Pandas从Excel工作表中读取超链接URL?

时间:2019-06-24 23:09:16

标签: python pandas

我正在尝试使用Pandas从Excel工作表中读取值。该值是超链接。我想检索超链接链接到的URL,但是我不在乎超链接显示的名称。例如,excel工作表可能会在“文档”名称下显示一个超链接,但它会将我发送到www.facebook.com。我想检索URL“ www.facebook.com”,并且我不在乎“ document”的值。如何使用Python的Pandas软件包

我已经创建了整个excel工作表的数据框,并使用“对于df.iterrows()中的行用于索引,”来遍历每一行。 “行”是系列类型。当我达到所需的值并使用“ row [” ...包含超链接的列名称...]“时,将返回超链接的名称,而不是URL(我要检索的URL)< / p>

# Read Excel sheet
df = pandas.read_excel('C:/Users/.....xlsx', sheet_name=1, keep_default_na=False) 

# Walk through each row in the excel sheet
for index, row in df.iterrows():

     # This only gives name of the link - not the actual URL
     link = row["website link"]

0 个答案:

没有答案