I don’t have an answer to the “why doesn’t this work?” portion of the question. However to simply ignore the warning you can use warnings.catch_warnings
with warnings.simplefilter
as seen here.
import warnings
with warnings.catch_warnings():
warnings.simplefilter("ignore")
your_code()
Obviously, I don’t recommend ignoring the warning unless you’re sure its harmless, but if you’re going to do it this way will only suppress warnings inside the context manager and is straight out of the python docs