def time_constant_values(time_value, df, band_list):
try:
time_value in df.index
except KeyError:
print('The time value does not exist!')
else:
constants = []
for band in band_list:
constants.append(df.loc[time_value][band])
t0_dict = dict(zip(band_list, constants))
return t0_dict
熊猫数据帧包含格式为hh:mm:ss的索引中的时间值。我在做什么除错部分?在索引中搜索熊猫数据帧中的值
我想访问特定的时间行为某些colummns,然后形成一个字段列标签作为键和数据值作为值。
谢谢!
我在这里看到了很多东西,首先什么是你想在你的try块做的,并且有一个else语句没有如果。 – bhansa
@bhansa其他部分是好的(有效的Python语法),还有其他问题... –
如果您发现它有用,请接受答案,并坚持一个答案。谢谢。 –