How can I best calculate if a datum is above or below the mean?

1634
1
02-12-2016 12:40 AM
JasonRichardson1
New Contributor

         All,

First time posting and I have searched for this issue but didn't find where it was previously addressed.  I have added a field call "Loans" and it contains hundreds or thousands of numbers including zeros and decimals.

I also have a new field called LoanScore

Compute the mean of Loans and if the item on that row is above the mean assign a "1" to that row in LoanScore.

I am running ArcGIS 10.3.1 and Python 10.3.1 on 64 bit Windows.

Previously, I was able to run this in excel using the statement =if(median(a$2:a$1000)<a2,1,0) and then just filled the whole LoanScore column with that formula [where a2 was the first number in the "Loans" column]

Thank you for any assistance.

0 Kudos
1 Reply
DanPatterson_Retired
MVP Esteemed Contributor

You would have to know what the mean was ahead of time if you intend to do this in the field calculator since field calculations proceed row by row and they do not do column statistics prior to calculating a value for an individual row like spreadsheets do.  You could get the mean/median value using summary statistics then proceed with the calculation. 

Alternately, you would have to script the calculation to determine the mean first then use this value in the Calculate

Field tool Calculate Field—Help | ArcGIS for Desktop Remember, calculations in tables for spatial data are not like those in spreadsheets and you will have to amend your workflow accordingly