Thursday 28 July 2022

get idxmax rolling for each group and each row?

data: https://github.com/zero-jack/data/blob/main/hy_data.csv#L7

Goal

  • get the idxmax from last n rows for each group.

Try

df=df.assign(
        l6d_highest_date=lambda x: x.groupby('hy_code')['high'].transform(lambda x: x.rolling(6).idxmax())


AttributeError: 'Rolling' object has no attribute 'idxmax'

notice: week_date is the index.



from get idxmax rolling for each group and each row?

No comments:

Post a Comment