I have created a dataframe with pandas. There are more than 1000 rows I want to merge rows of overlapping columns among them.
For convenience, there are example screenshots made in Excel. I want to make that form in PYTHON.
I want to make the above data like below
CodePudding user response:
This should be as simple as setting the index.
df = df.set_index('Symbol', append=True).swaplevel(0,1)
Output should be as desired.