Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def apply_diff_func(df):
- df['difference'] = df['col'].diff()
- return df
- outputdf = df.groupby('storeid').apply(apply_diff_func)
- def apply_shift_func(df):
- df['shifted'] = df['col'].shift(1)
- df['difference'] = df['col'] - df['difference']
- return df
- outputdf = df.groupby('storeid').apply(apply_diff_func)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement