识别值后如何显示列标题

2024-06-14 04:49:10 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在分析excel电子表格,需要找到包含最接近但小于500的值的单元格。我相信我已经实现了这一点,但需要知道相应的标题名称,我无法确定如何操作

loc=("/Volumes/Project/Andes_Glacier_Inventory.xlsx")
wb = xlrd.open_workbook(loc)
sheet = wb.sheet_by_index(1)
headers = sheet.row(0)
print(sheet.row_values(1,3))

a = np.array(sheet.row_values(1,3))

value = 501
print (a[a<value].max())

Tags: project名称标题valueexcellocsheetrow