我有一个按ID
列分组的时间序列数据.
我try 使用以下代码:
def find_peaks_in_group(group):
peaks, peak_properties = find_peaks(group['RFPower'], prominence=1, height=0.7)
group['peaks'] = False
group.loc[peaks, 'peaks'] = True
group['peak_heights'] = 0.0
group.loc[peaks, 'peak_heights'] = peak_properties['peak_heights']
return group
result_df=df.groupby('ID', group_keys=False).apply(find_peaks_in_group)
但是,我收到了一个键错误:
[Int64Index([76116,76134,76146,76150,76155,76161,76165, 76171、76177、76180、76182、76185、76187、76192、76196、76201、76220、 76224、76230、76235、76240、76242、76247、76252、76257、76276、76282、 76286、76292、76295、76297、76302、76307、76337、76348、76350、76362 76364,77324,93723,94851,94855],dtype=‘int64’)]中 [索引]"
我甚至试着go 掉group_keys=False
并重新设置索引,但都无济于事.
有什么建议吗?