I ave acquired a pandas dataframe that has a multi-index via the code below:
price_data = yf.dpwnload(tickers = tickers_str, period = "2y", interval = "1wk", group_by = 'ticker')
The acquired dataframe is shown in the image below.
How can I turn this dataframe into single-index?
Columns of dataset:
( 'SOKM.IS', 'Open'),
( 'SOKM.IS', 'Close'),
('EGEEN.IS', 'Open'),
('EGEEN.IS', 'Close'),...
Desired output:
- Column name must be the first index (i.e. "SOKM.IS", "EGEEN.IS", etc.)
- value must be the value at "Close" index of 2nd index