I have the following dataframe:
data = {'POSTING_AMOUNT1': [10,20,30], 'POSTING_AMOUNT2': [100,200,300],
'POSTING_AMOUNT3': [15,25,35], 'POSTING_AMOUNT4': [20,40,60]}
My expected output needs to be as follows:
Column | Posting_Amount |
---|---|
1 | 10 |
1 | 20 |
1 | 30 |
2 | 100 |
2 | 200 |
2 | 300 |
3 | 15 |
3 | 25 |
3 | 35 |
4 | 20 |
4 | 40 |
4 | 60 |
I have tried using the pandas .melt function with no luck. The issue I think is that I am manually trying to assign labels to the 'Column' column. This is what I attempted amongst other tries:
melted = pd.melt(df, id_vars=[1,2,3,4], value_vars=['POSTING_AMOUNT1', 'POSTING_AMOUNT2', 'POSTING_AMOUNT3',
'POSTING_AMOUNT4'], var_name='Column', value_name='Posting_Amount')