df = df.applymap(int)
rowsums = pd.concat([df.sum(axis=1)] * 2, ignore_index=True, axis=1)
colsums = pd.concat([df.sum(axis=0)] * 2, ignore_index=True, axis=1).transpose(
    )
colsums.index = rowsums.index
rowsums.columns = colsums.columns
newdata = colsums * rowsums
newdata = newdata.divide(df.sum().sum())
Apply row and column sum to cell in pandas data frame