During the project, we are instructed to split up a dataframe into slices like this:
Later on, in the project, we are instructed to insert some code which is written for us. It work well, but it causes a “SettingWithCopyWarning” as you can see.
I believe this is because we are adding a column to
day, a slice of the original dataframe. I believe I can avoid the warning if I add the
month column to the original dataframe before I split it into slices. Is that a better practice? Is there another, better solution? Should I just ignore it? Is there a way to turn off this warning?
Hey! Dataquest has a post about SettingWithCopyWarning issue here.
If you want to turn off all the warnings, you can:
(Be sure to put it at the BEGINNING of your import libraries section)
However, quite often it is useful to see a warning once. This can be set by:
warnings.filterwarnings(action = 'once')
Thanks for the info and the link. I also saw some info about this in someone else’s question about my current project, a question I also had about using
.copy(). I still have to read what you linked more thoroughly, but it seems that could help me avoid warnings as well.