Normalizing a pandas DataFrame by row
To overcome the broadcasting issue, you can use the div
method:
df.div(df.sum(axis=1), axis=0)
See pandas User Guide: Matching / broadcasting behavior
To overcome the broadcasting issue, you can use the div
method:
df.div(df.sum(axis=1), axis=0)
See pandas User Guide: Matching / broadcasting behavior