I have an empty table with an integer type field, let us call it "field1"
I want to populate field1 with numbers ranging from 1-5, so that my table looks like this
OBJECTID FIELD1
1 1
2 2
3 3
4 4
5 5
I have come across this example - How To: Create sequential numbers in a field using Python in the Field Calculator
But do not know how to adapt it to fit my need.
Regards,
Similar question to In Field Calculator 1 To 9 Loop Numbers.
Pre-Logic Script Code:
<SPAN class="keyword token">from</SPAN> itertools <SPAN class="keyword token">import</SPAN> cycle rot <SPAN class="operator token">=</SPAN> cycle<SPAN class="punctuation token">(</SPAN>range<SPAN class="punctuation token">(</SPAN><SPAN class="number token">1</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="number token">6</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">def</SPAN> <SPAN class="token function">next_number</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="keyword token">return</SPAN> next<SPAN class="punctuation token">(</SPAN>rot<SPAN class="punctuation token">)</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
Value:next_number()
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.