Boolean masking error question

Hey all. I am stumped! I am trying to use a boolean mask based on multiple criteria and I keep getting the dreaded “SettingWithCopyWarning”.

Here’s what I’ve got:



I am trying to have the field updated with “16-MDS” if it meets the three conditions in the mask.

When it runs I get the SettingWithCopyWarning.

Any advice would be greatly appreciated.



This Dataquest article might help you understand why you get the SettingWithCopyWarning and what you might be able to do about it.

I tried that first, but I couldn’t figure out how to apply it to this scenario.


Since I don’t know what data you’re working with or your notebook, it’s hard to say why you’re getting the warning. Just to play around a bit, I tried taking just a random data set and mimicking creating a mask like you have to see if I get the warning too, but it didn’t happen. :woman_shrugging: I know sometimes in our missions we’re told to add .copy() or to put in an errors='ignore' parameter, but I’ll have to go back and review to understand why we did that in those scenarios. (Adding that to my list of topics to review in more depth!)

Hopefully someone on here with more experience and knowledge might have some insight!

Is AFBRevenue derived from another dataframe?
If yes, you can add copy() on the right hand side of the assignment of AFBRevenue =
I have read that article 3 times and still find it difficult to come up with a mindmap of what is going on. Also feel it’s not worth the time

Thanks! I will give it a shot when I am back in the office.

I am somewhat determined to understand that warning. It seems like the kind of thing that, if you ignore it, it could come back to bite you.