pandas read_excel与超链接 [英] Pandas read_excel with Hyperlink
问题描述
df = pd.read_excel( xls)
但是,电子表格的其中一列包含与其相关联的超链接的文本。如何访问熊猫中的基础超链接?
这可以用openpyxl完成,我不知道它是否可能熊猫在所有。以下是我如何做:
import openpxyl
wb = openpyxl.load_workbook('yourfile $ x
ws = wb.get_sheet_by_name('Sheet1')
print(ws.cell(row = 2,column = 1).hyperlink.target)
您还可以使用iPython,并设置与超链接对象相等的变量:
t = ws.cell(row = 2,column = 1).hyperlink
然后执行 t。
,然后按选项卡查看所有可以使用或从对象访问的选项。
I have an Excel spreadsheet that I am reading into a Pandas DataFrame:
df = pd.read_excel("file.xls")
However, one of the columns of the spreadsheet contains text which have a hyperlink associated with it. How do I access the underlying hyperlink in Pandas?
This can be done with openpyxl, I'm not sure its possible with Pandas at all. Here's how I've done it:
import openpxyl
wb = openpyxl.load_workbook('yourfile.xlsm')
ws = wb.get_sheet_by_name('Sheet1')
print(ws.cell(row=2, column=1).hyperlink.target)
You can also use iPython, and set a variable equal to the hyperlink object:
t = ws.cell(row=2, column=1).hyperlink
then do t.
and press tab to see all the options for what you can do with or access from the object.
这篇关于 pandas read_excel与超链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!