<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Field Calculator: Generate Random Numbers failure in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/field-calculator-generate-random-numbers-failure/m-p/383677#M30212</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;stupids finally over&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;parser:&amp;nbsp; Python&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Code block&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
import numpy
def rand_num(a_field):
&amp;nbsp; return&amp;nbsp; numpy.random.randint(1,1000)
&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;the rest&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;rand_num(!randnum!)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;where !randnum! is the field to place the random numbers.&amp;nbsp; I think you were mixing up the script example with the field calculator example and I just didn't catch it&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;or better still provide a minimum and maximum value&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
import numpy
def rand_num(min_val, max_val):
&amp;nbsp; return&amp;nbsp; numpy.random.randint(min_val,max_val)
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;with&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;rand_num(1,1000)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;calling the function&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 17:39:29 GMT</pubDate>
    <dc:creator>DanPatterson_Retired</dc:creator>
    <dc:date>2021-12-11T17:39:29Z</dc:date>
    <item>
      <title>Field Calculator: Generate Random Numbers failure</title>
      <link>https://community.esri.com/t5/python-questions/field-calculator-generate-random-numbers-failure/m-p/383669#M30204</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm new to python so hopefully the solution is simple. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am trying to generate random integers between 1 and 1000 to populate the field "Rand2".&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The "Rand2" field is Float.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;####&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Pre-Logic Script Code:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;import arcpy&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Set the randomGenerator environment to 4 MERSENNE_TWISTER&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.env.randomGenerator = "4 MERSENNE_TWISTER"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Calculate a random number using the arcgis.rand() function &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;result = arcpy.CalculateValue_management("arcgis.rand('INTEGER 1, 1000')") &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Get the value from the result object from CalculateValue and print &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;randomValue = float(result.getOutput(0)) &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;print randomValue &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Expression:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Rand2=&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;randomValue[!Rand2!]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;####&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Field calculator runs for a while then delivers an "Error running expression" message (See image for full message).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Can anyone tell me how to clean this up?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Rich&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Feb 2011 14:08:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/field-calculator-generate-random-numbers-failure/m-p/383669#M30204</guid>
      <dc:creator>RichardThurau</dc:creator>
      <dc:date>2011-02-25T14:08:52Z</dc:date>
    </item>
    <item>
      <title>Re: Field Calculator: Generate Random Numbers failure</title>
      <link>https://community.esri.com/t5/python-questions/field-calculator-generate-random-numbers-failure/m-p/383670#M30205</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;if getoutput returns a list, then this line&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;randomValue = float(result.getOutput(0)) &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;should be&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;randomValue = float(result.getOutput[0])&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Feb 2011 15:21:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/field-calculator-generate-random-numbers-failure/m-p/383670#M30205</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2011-02-25T15:21:38Z</dc:date>
    </item>
    <item>
      <title>Re: Field Calculator: Generate Random Numbers failure</title>
      <link>https://community.esri.com/t5/python-questions/field-calculator-generate-random-numbers-failure/m-p/383671#M30206</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks Dan,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I made the change. But, still not functioning. Now error message is:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;type 'exceptions.TypeError'&amp;gt;: 'instancemethod' object is unscriptable.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Progress? &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;not sure&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Rich&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Feb 2011 17:04:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/field-calculator-generate-random-numbers-failure/m-p/383671#M30206</guid>
      <dc:creator>RichardThurau</dc:creator>
      <dc:date>2011-02-25T17:04:24Z</dc:date>
    </item>
    <item>
      <title>Re: Field Calculator: Generate Random Numbers failure</title>
      <link>https://community.esri.com/t5/python-questions/field-calculator-generate-random-numbers-failure/m-p/383672#M30207</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;so it isn't returning a python list, however, looking at the help files and your example I noted&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;'INTEGER 1, 1000' was your case&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;and in the help files at&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//001w0000000w000000.htm"&gt;http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//001w0000000w000000.htm&lt;/A&gt;&lt;BR /&gt;&lt;SPAN&gt;it was&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;'normal 0.0 10.0'&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;the only difference between them, excluding the distribution type, was that you had a pesky "," after the 1 in yours and the help files seems to suggest that a space delimited string is used.&amp;nbsp; Barring that, try the help file example to rule out further issues.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Feb 2011 17:55:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/field-calculator-generate-random-numbers-failure/m-p/383672#M30207</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2011-02-25T17:55:44Z</dc:date>
    </item>
    <item>
      <title>Re: Field Calculator: Generate Random Numbers failure</title>
      <link>https://community.esri.com/t5/python-questions/field-calculator-generate-random-numbers-failure/m-p/383673#M30208</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Yes, I've been trying all sorts of variations based on that example and what I can read about the function. From what I can see in the error messages, commas and capitalizations don't seem to matter too much.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I did try the tool originally using the provided script exactly as presented.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Either the documentation is wrong for arcgis.rand(), the documentation is leaving out some vital steps, I'm doing something wrong that no one has pointed out, or arcpy is screwed up on my machine.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Still trying though.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;RT&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Feb 2011 18:11:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/field-calculator-generate-random-numbers-failure/m-p/383673#M30208</guid>
      <dc:creator>RichardThurau</dc:creator>
      <dc:date>2011-02-25T18:11:21Z</dc:date>
    </item>
    <item>
      <title>Re: Field Calculator: Generate Random Numbers failure</title>
      <link>https://community.esri.com/t5/python-questions/field-calculator-generate-random-numbers-failure/m-p/383674#M30209</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;instead of &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;randomValue[!Rand2!]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;try&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;randomValue(!Rand2!)&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Feb 2011 19:03:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/field-calculator-generate-random-numbers-failure/m-p/383674#M30209</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2011-02-25T19:03:10Z</dc:date>
    </item>
    <item>
      <title>Re: Field Calculator: Generate Random Numbers failure</title>
      <link>https://community.esri.com/t5/python-questions/field-calculator-generate-random-numbers-failure/m-p/383675#M30210</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You are a trooper Dan.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;That was one of the first things I noticed between the code example in help, and the code examples that I saw others post.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I just tried it again anyway, with not success. I even got rid of defining the distribution. Current code block is:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;import arcpy&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Calculate a random number using the arcgis.rand() function &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;result = arcpy.CalculateValue_management("arcgis.rand('normal 0.0 10.0')") &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Get the value from the result object from CalculateValue and print &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;val = float(result.getOutput[0]) &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;print val&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Expression is:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;val(!Rand2!)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I had to move on, so I generated a random table of values on Random.org's website, pasted into excel, joined the excel file, and used field calculator to copy the random values. That's a lot of work for what should be a simple code.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Of course I wouldn't spend so much time if I didn't think this was going to helpful to me in the future.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Therefore, i would greatly appreciate any attempts to find a fix.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks a lot.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Rich&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Feb 2011 19:17:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/field-calculator-generate-random-numbers-failure/m-p/383675#M30210</guid>
      <dc:creator>RichardThurau</dc:creator>
      <dc:date>2011-02-25T19:17:53Z</dc:date>
    </item>
    <item>
      <title>Re: Field Calculator: Generate Random Numbers failure</title>
      <link>https://community.esri.com/t5/python-questions/field-calculator-generate-random-numbers-failure/m-p/383676#M30211</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Rich&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I will look into it some more, try the code block that uses numpy's random in the interim&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Feb 2011 19:28:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/field-calculator-generate-random-numbers-failure/m-p/383676#M30211</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2011-02-25T19:28:11Z</dc:date>
    </item>
    <item>
      <title>Re: Field Calculator: Generate Random Numbers failure</title>
      <link>https://community.esri.com/t5/python-questions/field-calculator-generate-random-numbers-failure/m-p/383677#M30212</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;stupids finally over&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;parser:&amp;nbsp; Python&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Code block&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
import numpy
def rand_num(a_field):
&amp;nbsp; return&amp;nbsp; numpy.random.randint(1,1000)
&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;the rest&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;rand_num(!randnum!)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;where !randnum! is the field to place the random numbers.&amp;nbsp; I think you were mixing up the script example with the field calculator example and I just didn't catch it&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;or better still provide a minimum and maximum value&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
import numpy
def rand_num(min_val, max_val):
&amp;nbsp; return&amp;nbsp; numpy.random.randint(min_val,max_val)
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;with&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;rand_num(1,1000)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;calling the function&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 17:39:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/field-calculator-generate-random-numbers-failure/m-p/383677#M30212</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2021-12-11T17:39:29Z</dc:date>
    </item>
    <item>
      <title>Re: Field Calculator: Generate Random Numbers failure</title>
      <link>https://community.esri.com/t5/python-questions/field-calculator-generate-random-numbers-failure/m-p/383678#M30213</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Well, this isn't very clear to me. I tried both examples you've given here. At least in a way I am interpreting. ArcGIS doesn't want to calculate either of them. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Like I said, I'm really new to using python, and I haven't successfully gotten anything to run from Filed Calculator yet.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I guess the question is, does this code work on your machine? I'm starting to think there could be something wrong with python or something on my machine.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I've attached an image of the code I'm trying to populate my Rand2 field with.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;RT&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 26 Feb 2011 14:23:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/field-calculator-generate-random-numbers-failure/m-p/383678#M30213</guid>
      <dc:creator>RichardThurau</dc:creator>
      <dc:date>2011-02-26T14:23:44Z</dc:date>
    </item>
    <item>
      <title>Re: Field Calculator: Generate Random Numbers failure</title>
      <link>https://community.esri.com/t5/python-questions/field-calculator-generate-random-numbers-failure/m-p/383679#M30214</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;did you try the second as well?&amp;nbsp; is your field an integer field?&amp;nbsp; worked on my computer&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 26 Feb 2011 19:38:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/field-calculator-generate-random-numbers-failure/m-p/383679#M30214</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2011-02-26T19:38:48Z</dc:date>
    </item>
    <item>
      <title>Re: Field Calculator: Generate Random Numbers failure</title>
      <link>https://community.esri.com/t5/python-questions/field-calculator-generate-random-numbers-failure/m-p/383680#M30215</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Dan,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks so much for keeping it up. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Well, looks like my error is data specific. I don't know why yet, but that code will not run on the dataset I've been trying to generate random numbers for. However, it did run perfectly on another shapefile (that has far fewer features?).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It ran on a Long field (I had been trying both Long and Float).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;At least now I know that numpy at least works on my machine.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;There used to be a way to mark issues as solved on these forums, but I'm not seeing that option right now.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for your help!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Rich&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 27 Feb 2011 16:30:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/field-calculator-generate-random-numbers-failure/m-p/383680#M30215</guid>
      <dc:creator>RichardThurau</dc:creator>
      <dc:date>2011-02-27T16:30:41Z</dc:date>
    </item>
    <item>
      <title>Re: Field Calculator: Generate Random Numbers failure</title>
      <link>https://community.esri.com/t5/python-questions/field-calculator-generate-random-numbers-failure/m-p/383681#M30216</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Just a check if it is that particular shapefile...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;1&amp;nbsp; File|Data Export Data give it a new name and saving location&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2&amp;nbsp; try the code on the "clone"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;or if you have some bad records&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;3&amp;nbsp; select the first couple of records in the table and try running the code on the selection&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;4&amp;nbsp; if that still doesn't work, select one record, export to a new file and try again.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;if that doesn't work...no clue&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 27 Feb 2011 17:42:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/field-calculator-generate-random-numbers-failure/m-p/383681#M30216</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2011-02-27T17:42:53Z</dc:date>
    </item>
    <item>
      <title>Re: Field Calculator: Generate Random Numbers failure</title>
      <link>https://community.esri.com/t5/python-questions/field-calculator-generate-random-numbers-failure/m-p/383682#M30217</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Dan,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I've messed around with a few things. The code runs on some datasets but not others (does not run on an exported copy of original). Neither file name length, nor the number of records seems to matter. It ran on some polygon shapefiles but not others. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The key for me was just to figure this code out because it's a tool I will be able to use in the future. Hopefully, when that time comes, I'll either have a dataset with which the code works, or I'll figure out why it doesn't.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;But, till then, I'm moving on.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks again for your help. I was going a little nuts there for a bit.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Rich&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 Feb 2011 13:20:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/field-calculator-generate-random-numbers-failure/m-p/383682#M30217</guid>
      <dc:creator>RichardThurau</dc:creator>
      <dc:date>2011-02-28T13:20:45Z</dc:date>
    </item>
    <item>
      <title>Re: Field Calculator: Generate Random Numbers failure</title>
      <link>https://community.esri.com/t5/python-questions/field-calculator-generate-random-numbers-failure/m-p/383683#M30218</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;If you are still looking at this, I had luck with a slight variation of the code block given above:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;(code block)&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
def rand_num():
&amp;nbsp; import random
&amp;nbsp; return random.randint(1,100)
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;then &lt;/SPAN&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
(yourField) = rand_num()
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 17:39:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/field-calculator-generate-random-numbers-failure/m-p/383683#M30218</guid>
      <dc:creator>deleted-user-ugCMpXci8bn5</dc:creator>
      <dc:date>2021-12-11T17:39:32Z</dc:date>
    </item>
    <item>
      <title>Re: Field Calculator: Generate Random Numbers failure</title>
      <link>https://community.esri.com/t5/python-questions/field-calculator-generate-random-numbers-failure/m-p/383684#M30219</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;For posterity, if you are hitting a data specific error, you can throw some debugging code in the script to see which records are giving you problems.&amp;nbsp; In this case, you could pass in the ObjectID to the field calculator function and put it in and arcpy.AddMessage note.&amp;nbsp; This way you would see how far things get before hitting the error.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 28 Apr 2015 20:04:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/field-calculator-generate-random-numbers-failure/m-p/383684#M30219</guid>
      <dc:creator>JeffWard</dc:creator>
      <dc:date>2015-04-28T20:04:11Z</dc:date>
    </item>
  </channel>
</rss>

