How to obtain the percentage of each value from a pandas table?
<p>I have a table with 5 columns: AWA, REM, S1, S2 and SWS. I computed the sum of each column and of each row. And also the percentages of these values. But in order to get the percentages I repeated the same line 5 times. 
Is there a way to improve it in case there were more than 5 columns?</p>

<p>Here is my code and I have also attached an image. </p>

<pre><code>    import pandas as pd

    df = pd.DataFrame(TABLA, columns=('AWA', 'REM', 'S1', 'S2', 'SWS'))
    df.index='s' + (df.index+1).astype(str) 
    df['xSubject'] = df.sum(axis=1) #sums each colummn

    ######Here starts the repetition:
    df['AWA%'] = df['AWA']/df['AWA'].sum()*100
    df['REM%'] = df['REM']/df['REM'].sum()*100
    df['S1%'] = df['S1']/df['S1'].sum()*100
    df['S2%'] = df['S2']/df['S2'].sum()*100
    df['SWS%'] = df['SWS']/df['SWS'].sum()*100
    df['xSubject%'] = df['xSubject']/df['xSubject'].sum()*100
    ######Here ends the repetition:

    df.loc['xStage'] = df.sum() #sums each row

    df
</code></pre>

<p><a href="https://i.stack.imgur.com/trO6j.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/trO6j.png" alt="enter image description here"></a></p>