anyone know of a simple way to report the following on an attribute table?
Example:
Depends on how "simple" you want.
One simple way is to load into Pro/ArcMap and symbolize on the Phase Configuration field, then select Show Counts.
R_
Quick and rough implementation; replace "table = poly_selection[0]" with a reference to your own table...
''' A short script to: 1. Get the list of fields from a table, 2. Iterate every row of the table (using da.SearchCursor) 3. Use list and dictionary to collect 3a. List of fields, dictionary of values, count of occurrences 3b. Optionally, limit # of unique values to report. 4. Prints results to the console. ''' import arcpy ### PREPROCESS FOR LIVING ATLAS poly = "https://services2.arcgis.com/FiaPA4ga0iQKduv3/arcgis/rest/services/USA_Block_Groups_v1/FeatureServer/0" poly_layer = arcpy.management.MakeFeatureLayer(poly, "Atlas Census Blocks LayerView") poly_selection = arcpy.management.SelectLayerByAttribute( in_layer_or_view = poly_layer, where_clause = "COUNTY = '173' And STATE = '37'" ) ### Unique Values, All Fields from Table: ## My Table... table = poly_selection[0] ## Get the List of Fields from My Table fields = arcpy.ListFields(table) ## Empty Results: fields_list = [] # list fields_summary = {} # dictionary ## List of Fields, and a 'Summary' Results Dictionary for field in fields: fields_list.append(field.name) fields_summary[field.name] = [field.type, field.length, {}] print('Found', len(fields_summary), 'fields.') ## Now, try to Collect and Count values for every Field: with arcpy.da.SearchCursor(table, fields_list) as sCursor: for row in sCursor: # for each row, for index,item in enumerate(fields_list): # for each field value_dict = fields_summary[item][2] if len(value_dict) > 100: ## limit number of unique_values to manage value_dict['MORE VALUES'] = value_dict.get('MORE VALUES', 1) + 1 else: value_dict[row[index]] = value_dict.get(row[index], 1) + 1 ## Print our results: for key in fields_summary: print('Field:',key,'\n', fields_summary[key], '\n')
Echoing the comment above from Dan that the Summary Statistics tool would probably be a good starting point.
The graphic on the documentation's help page shows a visual example of how it'd work for your table.
The tool will output a table, containing each unique value in the field and the count of how many times this value occurs.
Alternatively, if you wanted to give Python a go a workflow along the lines of the following might be suitable:
There is a built in python module called "collections" and within this the "counter" class can be used to count the occurrences of items in a list or iterable.
through model builder with a field iterator calling
Summary Statistics (Analysis)—ArcGIS Pro | Documentation with the "count" option
obviously, only for fields of Text type
Iterate Fields (ModelBuilder)—ArcGIS Pro | Documentation
Or if you want other statistics for interval/ratio data type fields, you could accommodate that as well
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.