upper_lower_bound
从我的数据帧返回2个日期时间索引。我一次只使用一个,它们之间没有关系
我想从数据帧highP
中获取前6行数据的max()
值,但如果尝试从中减去6,则会出现错误dt.timedelta(6)
从df中减去6天,但df中缺少天数,因此无法提供正确答案
我如何切片highP
,以便它为我提供该系列中eg的前六个值
highP.loc[i - 6: i].max()
假设i
是一个日期时间索引
任何帮助都将不胜感激
upper_lower_bound = df[(isoHL['IH'] >= 1) | (isoHL['IL'] >= 1)].index[-3:-1]
if isoHL.loc[upper_lower_bound[-1]]['IH'] == 1 and isoHL.loc[upper_lower_bound[-1]]['IL'] == 0:
upper_bound = highP.loc[upper_lower_bound[-1] - dt.timedelta(6):upper_lower_bound[-1]].max()
else:
pass
按时间排序并用尾部提取最后的元素怎么样? 出于一般性考虑,我将使用以下符号:
df
t
val
i
首先,我们获得样本随时间变化的df<;在
i
的时间:before_df = df[df['t'] <= df.loc[i, 't']]
然后我们按时间排序:
before_df = before_df.sort_values(by=['t'])
然后我们用“尾巴”取最后五个:
five_before = before_df.tail(5)
然后我们将最大超值:
val = five_before['val'].max()
这能解决你的问题吗
`
相关问题 更多 >
编程相关推荐