How to suppress Pandas Future warning ?

I’ve been working some code with python and doing some operation with pandas library.

I used to get future warning in the console like some method is going to changed or deprecated in the future.

So change it to something else like that.

For sometime, it was fine for me. Over period of time, it was bit annoying. Because I was looking for errors description or output in the console. But this future warning message is showing up regularly and reduced my focus towards main items I need to work on.

So I decided to hide those future warning message in the console for a moment. I was looking at the internet and found an generic way to do it.

By adding following line in the code, all the future warning has been hidden from the console.

import warnings
warnings.simplefilter(action='ignore', category=FutureWarning)
import pandas

Hope this will be helpful for someone in future or may be for myself.

Happy Coding!

Reference

https://github.com/pandas-dev/pandas/issues/2841#issuecomment-13382440


Related post -> Pandas “Can only compare identically-labeled DataFrame objects” error

Advertisement

2 thoughts on “How to suppress Pandas Future warning ?

  1. Carlos De Albuquerque January 28, 2023 / 12:12 am

    Thank you very much!

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s