I'm analysing an excel spreadsheet and need to find the cell that contains the value that is closest to, but less than 500. I believe I have achieved this but then need to know the corresponding header name which I cannot work out how to do.
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())
Use np.argmax
:
headers[np.argmax(a * (a<value))]