I am seeing a FutureWarning
in the output of my code, coming from the pandas
library.
I would like to catch when this is occurring in the code execution. The natural way would be to request pandas
to raise an exception rather than printing a warning message.
Is there way to do this? If an exception cannot be raised is there some other way of catching this condition during runtime?
2
Use Python’s built-in warnings
module:
# Convert FutureWarning to an exception
warnings.filterwarnings('error', category=FutureWarning)