I have to average 280 fields in 1 field. Each field has 300 rows.
That is my problem. I think I need a python script. I don't want to create a raster for each field and then use the raster calculator in ModelBuilder with iterations...
I don't know how to make that script in Python.
In this pic, the field "Prom_P2" is what I need to fill with the mean or average of the previous 280 fields.
This is code that @BERA shared with me, and it works:
import arcpy
shapefile = r'D:\PYTHON_practica\pp_1998_2015.shp'
field_names=[f.name for f in arcpy.ListFields(shapefile,wild_card='*Lay*')] #Create a list of all the fields with 'Lay' in field name
field_names.append('promedio') #add your mean field to the list
with arcpy.da.UpdateCursor(shapefile,field_names) as cursor:
for row in cursor:
row[-1]=sum(row[:-2])/len(row[:-2]) #Calculate mean and assign this to the mean field (-1)
cursor.updateRow(row)