Search code examples
pythonfinancestockyfinance

how I display yfinancedata witout the Date


import yfinance as yf
data = yf.download('AAPL')
print(data['Open'].tail(1).to_string())

the result is

Date            Open
2022-06-09    36.849998

I want to remove the date can anyone help me please?


Solution

  • print(data['Open'].values[1])
    

    the point is that the data is returned as a dataframe. If you want to extract a value, then use values in square brackets to specify the index. Since the indexes in this dataframe are dates, you can also extract them, for example:

    print(data['Open'].index[1])