I got stuck when calculating the median age in grouped data (age ranges) for each feature (each feature is a single administrative unit). I have about 18,000 features.
Field names indicate age ranges: 0-14, 15-64, 65-100. In the "median" field I would like to calculate the median age for each feature. I found a website https://atozmath.com/StatsG.aspx?q=1 where you can calculate such a median for a single feature, for example the first feature from the attribute table above.
The page easily calculated the median for the first feature in the image, and the page also wrote how it calculated it, but I don't know how to write a universal script for a "median" field to calculate the median for each feature.
Solved! Go to Solution.
What's the names of your columns? Are those aliases? I was guessing the spaces were underscores. Replace the names in the 'with arcpy.searchcursor ' line with their proper names
I've edited the code again. Copy and paste that in
Amended the code again
work, without error what now?
Wow, I'd test the results against your website, bear in mind it may have calculated lower class boundaries different from what you expected. Basically test quite a few features to see if correct result
but what should i do now to populate my column 'median' in attribute table?
You could pretty easily populate the column by copying and pasting the printed values into your blank column whilst editing the table. Are they correct?
I will export the table to excel and paste there the printed IDLE values into the "median" field. The values look fine, thank you for your patience and help