i'm trying to take the fcf from the most recent year but i am provided with the last four. is it possible to only receive the most recent?
this is what i tried:
import yfinance as yf
comp = yf.Ticker("META")
print(comp.cashflow.head(n=1))
this is what i receive: 2022-12-31 2021-12-31 2020-12-31 2019-12-31
Free Cash Flow 19044000000.0 39116000000.0 23632000000.0 21212000000.0
is it possible to just get the 2022-12-31 figure?
By default, comp.cashflow
retrieves the most recent four periods of cashflow data.
To access only the most recent FCF value, you can modify the code as follows:
import yfinance as yf
comp = yf.Ticker("META")
fcf = comp.cashflow.loc['Free Cash Flow']
most_recent_fcf = fcf[0]
print("Most recent FCF:", most_recent_fcf)
This retrieves the first column from the free cash flow array (which I assume is always the latest data point). If you are looking to get a specific date of FCF, then you can also modify it as such:
import yfinance as yf
comp = yf.Ticker("META")
most_recent_fcf = comp.cashflow.loc['Free Cash Flow', '2022-12-31']
print("Most recent FCF:", most_recent_fcf)