<?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: Replace values of None in Field Calculator? in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/replace-values-of-none-in-field-calculator/m-p/362152#M28585</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks for responding:)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Well, I just used the word "null" in the name of the function.&amp;nbsp; It actually runs without any gp errors/results, but nothing happens.&amp;nbsp; I'm guessing an if statement wasn't the right way to go.&amp;nbsp; Maybe an update cursor?&amp;nbsp; or could I have converted the field to a string, used .replace(), then converted back to an integer?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 03 Aug 2011 12:26:15 GMT</pubDate>
    <dc:creator>NickJacob</dc:creator>
    <dc:date>2011-08-03T12:26:15Z</dc:date>
    <item>
      <title>Replace values of None in Field Calculator?</title>
      <link>https://community.esri.com/t5/python-questions/replace-values-of-none-in-field-calculator/m-p/362150#M28583</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Can't seem to figure this one out.&amp;nbsp; I'm calculating a field with the field calculator, but not every row is populated with a value. Only about half are populated and the rest of the rows are Null.&amp;nbsp; I tried to define a python function to replace the Null values with 0, but no luck so far.&amp;nbsp; It looks something like this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;
#Code Block

def popNull(x):
&amp;nbsp; if x is Null:
&amp;nbsp;&amp;nbsp;&amp;nbsp; return 0

#Expression

= popNull(!Field!)
&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I suppose I should have used an update cursor?&amp;nbsp; As a work around I populated the entire field with a value of 0 before doing my real calc.&amp;nbsp; That filled in the gaps, but I'd still like to figure this out.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Aug 2011 02:44:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/replace-values-of-none-in-field-calculator/m-p/362150#M28583</guid>
      <dc:creator>NickJacob</dc:creator>
      <dc:date>2011-08-03T02:44:51Z</dc:date>
    </item>
    <item>
      <title>Re: Replace values of None in Field Calculator?</title>
      <link>https://community.esri.com/t5/python-questions/replace-values-of-none-in-field-calculator/m-p/362151#M28584</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Arc NULL is None in Python, so you need this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;#Code Block

def popNull(x):
&amp;nbsp; if x is None:
&amp;nbsp;&amp;nbsp;&amp;nbsp; return 0

#Expression

= popNull(!Field!)&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The error would have told you: global name 'Null' is not defined (if you hunted through the results window), that indicates to you that Null isn't right...&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 16:53:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/replace-values-of-none-in-field-calculator/m-p/362151#M28584</guid>
      <dc:creator>StacyRendall1</dc:creator>
      <dc:date>2021-12-11T16:53:07Z</dc:date>
    </item>
    <item>
      <title>Re: Replace values of None in Field Calculator?</title>
      <link>https://community.esri.com/t5/python-questions/replace-values-of-none-in-field-calculator/m-p/362152#M28585</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks for responding:)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Well, I just used the word "null" in the name of the function.&amp;nbsp; It actually runs without any gp errors/results, but nothing happens.&amp;nbsp; I'm guessing an if statement wasn't the right way to go.&amp;nbsp; Maybe an update cursor?&amp;nbsp; or could I have converted the field to a string, used .replace(), then converted back to an integer?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Aug 2011 12:26:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/replace-values-of-none-in-field-calculator/m-p/362152#M28585</guid>
      <dc:creator>NickJacob</dc:creator>
      <dc:date>2011-08-03T12:26:15Z</dc:date>
    </item>
    <item>
      <title>Re: Replace values of None in Field Calculator?</title>
      <link>https://community.esri.com/t5/python-questions/replace-values-of-none-in-field-calculator/m-p/362153#M28586</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Oh, duh.&amp;nbsp; I see what you're saying.&amp;nbsp; What I MEANT to say was.. yup, I did switch over to the word None after digging through the forums a bit.&amp;nbsp; Then, it runs but nothing happens.&amp;nbsp; The conclusion I've come to is that my approach was all wrong in the first place.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;a) simplest solution was to populate the whole field with a value of 0 first.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;b) if I wanted to hunt for values of None row by row, then using an update cursor in a stand alone script would likely be the way to go.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Aug 2011 21:56:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/replace-values-of-none-in-field-calculator/m-p/362153#M28586</guid>
      <dc:creator>NickJacob</dc:creator>
      <dc:date>2011-08-03T21:56:52Z</dc:date>
    </item>
  </channel>
</rss>

