我正在分析一个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())
答案 0 :(得分:0)
使用np.argmax
:
headers[np.argmax(a * (a<value))]