I'm running a bit of code to download stock information about various stocks using yfinance. I've been running this simplified bit of code for months now and have recently gotten "FutureWarning" errors when I run the following block of code
import pandas as pd
import yfinance as yf
print(yf.download('MMM', period='6h'))
The Error that I receive is the following: The 'unit' keyword in TimedeltaIndex construction is deprecated and will be removed in a future version. Use pd.to_timedelta instead. df.index+= _pd.TimedeltaIndex(dst-error_hours,'h')
I've tried using yfinance's start and end parameters to try and fix the issue, and have tried changing the period length and type, (period='10h', period='12y',etc). Everything I've done has given me the same error.
The warning is originating from the
yfinancelibrary itself, and it's related to the internal implementation of the library. Unfortunately, there's not much you can do directly within your code to suppress this warning, as it is being triggered by the library's own implementation details.However, you can temporarily suppress all FutureWarnings using Python's warnings module. Try this:
Output: