用法和ts中的差不多
def test():
i=[1,2,3,4]
for x in i:
yield x
for j in test():
print(j)
使用的时候就会返回一次值
实际使用中可以这样使用,例如我把df按照半小时进行分割,然后分别取处理每半小时的数据
def test():
final_df['raw_timestamp'] = pd.to_datetime(final_df['raw_timestamp'])
final_df['half_hour'] = final_df['raw_timestamp'].dt.floor(
f'{conf.log_time_span}min')
for _ , group in final_df.groupby('half_hour'):
yield group.drop('half_hour', axis=1).reset_index(drop=True)
for j in test():
pass