z score standardisation using categorical variable


I want to perform a z-score standardisation to be able to compare slaughterdata of several lines (in easy terms: different breeds) of pigs.
I found the following formula to calculate the z-score standardisation:

scipy.stats.zscore(a, axis=0, ddof=0, nan_policy=’propagate’)

However, I cannot understand how to do this if you want to use the average of a slaughter_variable of each linetype seperately as axis value. (where axis is the axis along which to calculate z-score).

As I have 12 different linetypes and around 20 different slaugther_variables I prefer to not programm and calculate everything seperately.

Is there anybody who has an idea to solve this problem


Less is more. Stay pure. Stay poor.
So you just want to do a conditional standardization? Meaning, standardize a bunch of continuous variables based on what category they are in?

Seem like you may be using Python?