HOW TO

Remove numbers from a string field in an attribute table in ArcGIS Pro

Last Published: July 4, 2024

Summary

In ArcGIS Pro, it is possible to remove the numerical values from a string field in an attribute table using a Python function. This is useful for data management, such as when only alphabetical values are required in a string field. This article provides the workflow to remove numbers from the values in a string field using the strip() Python function in the Calculate Field tool.

In this example, the numbers in the Street field are removed to display only non-numeric values.

Field in attribute table with numbers

Procedure

  1. Open the ArcGIS Pro project.
  2. In the Contents pane, right-click the feature layer and click Attribute Table.
  3. In the attribute table, right-click the field name, and select Calculate Field. In this example, the Street field is selected.
  4. In the Calculate Field window, specify the following parameters:
    1. For Input Table, ensure the layer selected in Step 2 is prefilled. In this example, the input table is Test.
    2. For Field Name, ensure the field selected in Step 3 is prefilled. In this example, the field name is Street.
    3. For Expression Type, select Python.
    4. For Expression, in the first expression box, specify the code provided below. Replace 'Field_Name' with the name of the field selected in Step 3.
strip_digits(!Field_Name!)
  1. In the Code Block box, specify the following expression.
import re
def strip_digits(s):
   return re.sub("\d+", "", s)
  1. Click the Verify icon to validate the expression.
  2. Click OK to run the script.
Python code in the Calculate Field window

The image below displays the Street field without numbers in the attribute table.

Field in attribute table without numbers

Article ID: 000030392

Software:
  • ArcGIS Pro 3 1
  • ArcGIS Pro 3 0
  • ArcGIS Pro 2 x

Receive notifications and find solutions for new or common issues

Get summarized answers and video solutions from our new AI chatbot.

Download the Esri Support App

Related Information

Discover more on this topic

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options