Just ran into this same question, and ended up using the python random.sample function directly to create a subsequence of rows from the original search cursor, e.g.
all_addresses <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">[</SPAN>row<SPAN class="punctuation token">.</SPAN>getValue<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"FID"</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">for</SPAN> row <SPAN class="keyword token">in</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>SearchCursor<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"survey_master_address_list_2018"</SPAN><SPAN class="punctuation token">,</SPAN> fields<SPAN class="operator token">=</SPAN><SPAN class="string token">"FID"</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="keyword token">import</SPAN> random sample_set <SPAN class="operator token">=</SPAN> random<SPAN class="punctuation token">.</SPAN>sample<SPAN class="punctuation token">(</SPAN>all_addresses<SPAN class="punctuation token">,</SPAN> sample_size<SPAN class="punctuation token">)</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
I tried a few times to just use row objects directly and found that there were weird reference issues, so it works best to pull a list of FID values, sample those, and then you can loop back through the layer using an UpdateCursor and check for `row.FID in sample_set` to then perform operations on the sample.
Aangemelde leden kunnen berichten plaatsen, updates volgen en meer. Nieuw hier? Registreer een gratis account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.