you could do this by chaining together rank and zscore like soindustry rank and standardize in [ ]by_industry apply(lambda xzscore( rank())out[ ]index entriesvtkgn to ptdqe data columnsmomentum non-null values shortinterest non-null values value non-null values dtypesfloat ( group factor exposures factor analysis is technique in quantitative portfolio management portfolio holdings and performance (profit and lessare decomposed using one or more factors (risk factors are one examplerepresented as portfolio of weights for examplea stock price' co-movement with benchmark (like & indexis known as its betaa common risk factor let' consider contrived example of portfolio constructed from randomly-generated factors (usually called the factor loadingsand some weightsfrom numpy random import rand fac fac fac np random rand( ticker_subset tickers take(np random permutation( )[: ]weighted sum of factors plus noise port series( fac fac fac rand( )index=ticker_subsetfactors dataframe({' 'fac ' 'fac ' 'fac }index=ticker_subsetvector correlations between each factor and the portfolio may not indicate too muchin [ ]factors corrwith(portout[ ] - the standard way to compute the factor exposures is by least squares regressionusing pandas ols with factors as the explanatory variables we can compute exposures over the entire set of tickersin [ ]pd ols( =portx=factorsbeta out[ ] - intercept financial and economic data applications www it-ebooks info