Select to view content in your preferred language

Is there a way to get the maximum value of a column in Field Calculator?

3023
5
04-20-2016 11:28 AM
FrankWakeley
Deactivated User

I want to have a function in my model that converts an arbitrary value to a percentage within that column's range. It would need to be dynamic. Right now I have:

def prob( Failure_Score 😞

   my_list = arcpy.da.TableToNumPyArray ("Failure_Score")

   my_max = max(my_list)

   percentage = (Failure_Score / my_max)*100

   return percentage

but it returns nothing. Really any advice would be greatly appreciated.

Thanks!

0 Kudos
5 Replies
AbdullahAnter
Honored Contributor

You can put  Summary Statistics tool and operate this for your field to get maximum value , then you can get this value by using Get Field Value tool , and use this Value in your expression.  

FrankWakeley
Deactivated User

Would I be able to input that value dynamically or would it be manually input each iteration?

0 Kudos
AbdullahAnter
Honored Contributor

if you put the tools in correctly way, the value will be generate dynamically each iteration.

0 Kudos
DuncanHornby
MVP Notable Contributor

The reason why your code above is failing is because you have not entered all the required parameters to the function TableToNumPyArray(). If you read the help file for this function you will see that it takes two parameters Table name and a list of fields, the remaining 3 parameters are optional. The Syntax section of the help file for any function explains the parameter order. You should spend some time getting yourself familiar in reading these documents.

WesMiller
Deactivated User

0 Kudos