【发布时间】:2019-01-06 11:09:06
【问题描述】:
我对 python 比较陌生,并试图找到包含值“3275”的单元格,即“newELA”。该值位于电子表格的第一行,是一个标题。这是我一直在尝试的:
loc=("/Volumes/Project/Andes_Glacier_Inventory.xlsx")
wb = xlrd.open_workbook(loc)
sheet = wb.sheet_by_index(1)
headers = sheet.row(0)[3:]
a = np.array(sheet.row_values(1,3))
value = 501
ELA = headers[np.argmax(a * (a < value))]
print ("The ELA is", ELA.value)
changeinELA = 100
value1 = changeinELA
value2 = ELA.value
newELA = float(value1) + float(value2)
print ("The new ELA is", newELA)
b = np.where (np.array(headers) == newELA)
print (b)
我得到的结果是,我什至不明白
(array([], dtype=int64),)
【问题讨论】:
-
能否提供完整的代码,比如
sheet是如何获得的? -
您的结果似乎是一个空的 numpy 数组。是的,正如@Pierre 建议的那样,你能提供更多代码吗?
-
用我目前使用的所有代码编辑
-
b是==为真的索引 - 在这种情况下没有任何索引。如果您向我们展示了headers和newELA,它可能会有所帮助。
标签: python arrays numpy header