I am using a library to get stock data. The data is then put into a df but in a nested form. I want to get data from two specific columns but the date column key is not recognised.
import numpy as np
from yahooquery import Ticker
mydata = Ticker('WMT', asynchronous=True)
# the above returns a yahoo.ticker.Ticker object)
df = mydata.history(period = '1m', interval = '1d'
# this creates a df with daily closing info for the month
If then look at the keys using df.keys() I get the following: Index(['low', 'close', 'high', 'open', 'volume', 'adjclose', 'dividends'], dtype='object')
I want to be able to have a flat df with two columns - date and close. How do I get that result? how do I even access the data in the 'date' column?
I am guessing the Ticker object is in json form but how can I tell? Unfortunately pd.json_normal(mydata) gives a 'NotImplementedError'.
The yahooquery library can be found at https://pypi.org/project/yahooquery/
Thanks in advance

I tried it out, and I believe you can use pandas.DataFrame.reset_index
Code:
Output: