ArcGIS API for Python Cookbook: Update string field storing boolean values to integer field with domain
Issue
Storing boolean attributes (e.g. Yes/No values) in a string field without any domain is the most common data quality issue I encounter when managing feature layers in ArcGIS Online/Enterprise. Doing so introduces the potential for data inconsistency, increases the complexity of maintenance/analysis, and wastes space. If this issue gets introduced, it tends to persist, since there’s currently no easy fix.
Solution
Here’s a quick snippet for updating a feature layer string field storing Yes/No values to an integer field with a Yes=1/No=0 domain: