I have the following dataframe:
df = pd.DataFrame({'a': [1, 2], 'b': [3, 4]})
df:
a b
0 1 3
1 2 4
I have a sample size N=5. I want to normalize the weights in the dataframe using
df.div(df.sum(axis=1), axis=0)
and enforce a constraint, such that none of the weights are greater than 1/sqrt(N).
Can this be done in one line?