pandas normalize groupby 1

pandas normalize groupby

df.groupby('indx').transform(lambda x: (x - x.mean()) / x.std())

Here is what the above code is Doing:
1. Grouping the dataframe by the ‘indx’ column
2. Applying a lambda function to each group
3. The lambda function takes the group as input and returns a transformed version of the group
4. The transformed version of the group is the group itself, but with the mean and standard deviation subtracted from each value

Similar Posts