For a while I've been using boxplot and definition query in ArcGIS to eliminate data outliers. It is a painful process when dealing with a lot of files and difficult to ensure the consistency.
I don't know much python but I want to try something like replacing outliers as `Null` in python parse of field calculator:
<SPAN class="keyword token">def</SPAN> <SPAN class="token function">function</SPAN><SPAN class="punctuation token">(</SPAN>x<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">:</SPAN>
qnt <SPAN class="operator token">=</SPAN> quantile<SPAN class="punctuation token">(</SPAN>x<SPAN class="punctuation token">,</SPAN> probs<SPAN class="operator token">=</SPAN>c<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="number token">25</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="punctuation token">.</SPAN><SPAN class="number token">75</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
H <SPAN class="operator token">=</SPAN> <SPAN class="number token">1.5</SPAN> <SPAN class="operator token">*</SPAN> IQR<SPAN class="punctuation token">(</SPAN>x<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
y<SPAN class="operator token">=</SPAN>x<SPAN class="punctuation token">;</SPAN>
y<SPAN class="punctuation token">[</SPAN>x <SPAN class="operator token"><</SPAN> <SPAN class="punctuation token">(</SPAN>qnt<SPAN class="punctuation token">[</SPAN><SPAN class="number token">1</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="operator token">-</SPAN> H<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="operator token">=</SPAN> <SPAN class="string token">""</SPAN><SPAN class="punctuation token">;</SPAN>
y<SPAN class="punctuation token">[</SPAN>x <SPAN class="operator token">></SPAN> <SPAN class="punctuation token">(</SPAN>qnt<SPAN class="punctuation token">[</SPAN><SPAN class="number token">2</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="operator token">+</SPAN> H<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="operator token">=</SPAN> <SPAN class="string token">""</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">return</SPAN> y<SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
Then output in my new field function`( !Yield_kg__! )` but it turns out failure below:
ERROR000539:Error running expression: function(0.0)
Traceback (most recent call last)
File "<expression>", line1, in <module>
File "<string>', line2, in function
NameError: globe name 'quantile' is not defined<SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
Can anyone tell me how to fix this?