I have the following Pandas DataFrame with 50 columns, it consists of the daily closing spot price and option price of a few selected stocks, 25 stocks in total but I am only showing 3 here. The prices shown here are just an example:
date tsla_spot tsla_options aapl_spot aapl_options msft_spot msft_options
2020-01-01 350 23.02 257.21 3.45 170.32 3.56
2020-01-02 345.64 21.32 260.10 3.79 123.45 43.21
2020-01-03 345.12 20.43 262.12 3.90 123.54 45.32
I want to have the following pandas dataframe, but can't figure out what how... Instead, is it known as pivot?
date stock spot options
2020-01-01 tsla 350 23.02
2020-01-01 aapl 257.21 3.79
2020-01-01 msft 170.32 3.56
2020-01-02 tsla 345.64 21.32
2020-01-02 aapl 260.10 3.79
2020-01-02 msft 123.45 43.21
Thank you in adv!