how I display yfinancedata witout the Date

Issue

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])

Answered By – inquirer

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published