You can use
df.div(df.sum(axis=1), axis=0)
df.sum(axis=1)
sums up each row; df.div(..., axis=0)
then divides.
Example:
import pandas as pd
df = pd.DataFrame({'a': [1, 2], 'b': [3, 4]})
>>> df.div(df.sum(axis=1), axis=0)
a b
0 0.250000 0.750000
1 0.333333 0.666667
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…