3

I have four fields in my table, (A,B,C,D). The field type is double with some fields being NULL. I used min(A,B,C,D) to return the smallest value and it works well if there are no NULL value in any of the fields . What would be the easiest way to return the minimum value that is not NULL?

I think I found a very simple way: min(filter(None,[!A!,!B!,!C!,!D!]))

  • What version of ArcGIS for Desktop are you using to do this? Can you include the relevant snippet from your Python "code so far", please? You can use the edit button beneath your Question to revise it with these details. – PolyGeo Jan 13 '14 at 6:14
6

You can do this which reads a little better IMO:

yourlist = [!A!,!B!,!C!,!D!]
min(x for x in yourlist if not x is None)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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