Understanding and avoiding the settingwithcopywarning in pandas