I have an attribute table with 100 columns (values are float and not NULL; more than 3000 rows). Using ArcGIS 10.6

  • I want to calculate the mean value of every field in a shapefile separately (like summary statistic works);
  • and use the resulting value for deleting the field: if the Mean value of the field lower than 0.6- delete the field from the table.

How can I use the Mean values of the fields in a for loop in order to delete the unnecessary fields from a table with python?

  • 2
    What have you tried? What are your python skills like? This would be s relatively simple coding exercise.
    – Hornbydd
    Jan 23, 2021 at 16:41
  • Basic python skill. I work with model builder mainly, but for this I can not find any solution.
    – GisT
    Jan 23, 2021 at 17:24

1 Answer 1


This would be difficult and I suspect overtly complex if implemented in modelbuilder, a python solution would be much easier to run.

Here is the code that will achieve what you need:

import arcpy
table = r"C:\Scratch\fGDB_Scratch.gdb\test"

# Creates an array using all fields in table
array = arcpy.da.TableToNumPyArray(table,"*")

# Create a list of field names
lstFields = list(array.dtype.names)

# Remove OBJECTID from list
# You add other fields to remove here, eg. text fields

# Compute mean and if it falls below limit add to delete list
print("identifying fields to delete...")
toDelete = list()
for fn in lstFields:
    if array[fn].mean() < 3.6:

# Drop fields
print("Deleting fields...")


Once you have modified this code to your case drop this code into the Python console window in ArcMap or run it from an IDE.

In my test scenario I have a table and I'm checking the mean of the fields to see if they are below the value of 3.6, obviously adapt it to your scenario. I would recommend you do this from a backed up version in case your logic was wrong. My test table was this:

Test table

  • 1
    Thank you!!! It works fine!
    – GisT
    Jan 23, 2021 at 21:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.