I have the following code for calculating z-score that works
def get_zscore(fundamental_df,columns):
numeric_df = fundamental_df.loc[columns]
means = numeric_df.mean(axis=1) # mean across securities
sds = numeric_df.std(axis=1) # SDs across securities
de_meaned = numeric_df.sub(means, axis=0)
return de_meaned.div(sds, axis=0)
myzscore = get_zscore(fundamental_df,[['ev_to_ebitda']])
I am trying to figure out what the simplest way to do this on per sector basis??
preferably something that does not involve looping through sectors.