<?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 calc help in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/field-calc-help/m-p/418869#M32888</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;In your function you need to feed in all of the fields you'll be using within the function to determine the return value. So your code should look something like this (after starting the field calculator on your "A_SqMi" field):&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
def Reclass(Updat_HYGR, Sq_Miles):
&amp;nbsp;&amp;nbsp;&amp;nbsp; if (Updat_HYGR == 'A'):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return Sq_Miles
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;Reclass(!Updat_HYGR!, !Sq_Miles!)&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;As an added note, if your field is not nullable you'll need to include an else statement that sets it too a predetermined invalid value (e.g. else: return -1).&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 18:57:06 GMT</pubDate>
    <dc:creator>BradPosthumus</dc:creator>
    <dc:date>2021-12-11T18:57:06Z</dc:date>
    <item>
      <title>Field calc help</title>
      <link>https://community.esri.com/t5/python-questions/field-calc-help/m-p/418867#M32886</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm trying to populate a field with an already defined area but only if the Updat_HYGR variable is = to 'A'&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;i have a column with letters A-D (Updat_HYGR), a Column with areas in sqmi (Sq_Miles) and a new column A_SqMi that i only want populated with the area if the Updat_HYGRP = 'A'&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;i just started using python but my statement looks like this&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;def Reclass(A_SqMi):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; if (Updat_HYGR == 'A'):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; return Sq_Miles&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Reclass(!A_SqMi!)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any help would be appreciated&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 Jun 2014 11:39:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/field-calc-help/m-p/418867#M32886</guid>
      <dc:creator>BenjaminMittler</dc:creator>
      <dc:date>2014-06-18T11:39:30Z</dc:date>
    </item>
    <item>
      <title>Re: Field calc help</title>
      <link>https://community.esri.com/t5/python-questions/field-calc-help/m-p/418868#M32887</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Couple notes: make sure the parser is set to Python (VBScript is the default), and Reclass isn't a good function name, because there's already a Reclass tool for rasters. Not saying it won't work, but at best it's confusing.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Anyway, you have to include the field(s) you use in the argument list.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;def myUpdate(hygrp, sqmile):
&amp;nbsp;&amp;nbsp;&amp;nbsp; # using upper() in case value is lower case a
&amp;nbsp;&amp;nbsp;&amp;nbsp; if hygrp.upper()== 'A': return sqmile


myUpdate(!Updat_HYGRP!, !Sq_Miles!)&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN style="font-family:verdana;"&gt;Another alternative is to just select by attribute features where Updat_HYGRP = 'A', then calculate those values to Sq_Miles. The Field Calculator will only calculate the selected records.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 18:57:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/field-calc-help/m-p/418868#M32887</guid>
      <dc:creator>Zeke</dc:creator>
      <dc:date>2021-12-11T18:57:03Z</dc:date>
    </item>
    <item>
      <title>Re: Field calc help</title>
      <link>https://community.esri.com/t5/python-questions/field-calc-help/m-p/418869#M32888</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;In your function you need to feed in all of the fields you'll be using within the function to determine the return value. So your code should look something like this (after starting the field calculator on your "A_SqMi" field):&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
def Reclass(Updat_HYGR, Sq_Miles):
&amp;nbsp;&amp;nbsp;&amp;nbsp; if (Updat_HYGR == 'A'):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return Sq_Miles
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;Reclass(!Updat_HYGR!, !Sq_Miles!)&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;As an added note, if your field is not nullable you'll need to include an else statement that sets it too a predetermined invalid value (e.g. else: return -1).&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 18:57:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/field-calc-help/m-p/418869#M32888</guid>
      <dc:creator>BradPosthumus</dc:creator>
      <dc:date>2021-12-11T18:57:06Z</dc:date>
    </item>
  </channel>
</rss>

