Let's start from creation of your source DataFrame:
df = pd.DataFrame(data=[
[ 'Item', 'FY20', 'FY21', 'FY22' ],
[ 'Case', 'High', 'Low', 'Base' ],
[ 'Multiple', 1.2, 2.3, 3.4 ],
[ 'Cash', 1.1, 1.4, 1.2 ]])
The result is:
0 1 2 3
0 Item FY20 FY21 FY22
1 Case High Low Base
2 Multiple 1.2 2.3 3.4
3 Cash 1.1 1.4 1.2
Then we have to:
- transpose this DataFrame,
- convert the first row into column names,
- change the first column name:
To do this, run:
df2 = df.transpose()
df2.columns = df2.iloc[0].tolist()
df2.drop(index=0, inplace=True)
df2.rename(columns={'Item': 'Date'})
The result is:
Date Case Multiple Cash
1 FY20 High 1.2 1.1
2 FY21 Low 2.3 1.4
3 FY22 Base 3.4 1.2
And to get your result, run:
df2.melt(id_vars=['Date', 'Case'], value_vars=['Cash'],
var_name='Name', value_name='Value')
and you will receive:
Date Case Name Value
0 FY20 High Cash 1.1
1 FY21 Low Cash 1.4
2 FY22 Base Cash 1.2
Or maybe the result should include also melting of Multiple column?
To achieve this, remove value_vars=['Cash'].
This way melting will include all remaining columns (other than
included in id_vars).