<?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: Problems with field Calculator and python scripting in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/problems-with-field-calculator-and-python/m-p/463183#M36308</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here's a way to do it using the Calculate Field tool, with a Python dictionary -- a little easier to work with if you have more than three categories....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Calculate Field&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Expression: &lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;mph(!CFCC2!)&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Parser:&lt;/P&gt;&lt;P&gt;PYTHON&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Code Block:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;speed = {"A3":30, "A4":30, "A5":35}
def mph(code):
&amp;nbsp; return speed&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;/PRE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 20:34:21 GMT</pubDate>
    <dc:creator>curtvprice</dc:creator>
    <dc:date>2021-12-11T20:34:21Z</dc:date>
    <item>
      <title>Problems with field Calculator and python scripting</title>
      <link>https://community.esri.com/t5/python-questions/problems-with-field-calculator-and-python/m-p/463181#M36306</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am trying to set up a drive time and I have classified a few roads in my attribute table as follows:&lt;/P&gt;&lt;P&gt;A5=35MPH&lt;/P&gt;&lt;P&gt;A4=30MPH&lt;/P&gt;&lt;P&gt;A3=20MPH&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So the codes A5, A4, A3 are in a field called CFCC2, My next step was to add a new field to the attribute table called speed. Currently all the values in speed are null. My question is, how can i create a python script so that I have something that will calculate the speeds of the roads based on the classification I have given them. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 30 Nov 2014 21:51:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/problems-with-field-calculator-and-python/m-p/463181#M36306</guid>
      <dc:creator>JakeKaufman1</dc:creator>
      <dc:date>2014-11-30T21:51:48Z</dc:date>
    </item>
    <item>
      <title>Re: Problems with field Calculator and python scripting</title>
      <link>https://community.esri.com/t5/python-questions/problems-with-field-calculator-and-python/m-p/463182#M36307</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Add a string field, use the field calculator emulating this&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14173869181044616 jive_text_macro" jivemacro_uid="_14173869181044616"&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 8pt;"&gt;"True" if !some_field! == "some_value" else ("other value" if !some_field! == "final_value" else "False")&lt;/SPAN&gt;&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;totally untried&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_14173869298834917" jivemacro_uid="_14173869298834917"&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 8pt;"&gt;"35MPH" if !CFCC2! == "A5" else ("30MPH" if !CFCC2! == "A4" else ("20MPH" if !CFCC2! == "A3" else "20MPH"))&lt;/SPAN&gt;&lt;/P&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 30 Nov 2014 22:34:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/problems-with-field-calculator-and-python/m-p/463182#M36307</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2014-11-30T22:34:59Z</dc:date>
    </item>
    <item>
      <title>Re: Problems with field Calculator and python scripting</title>
      <link>https://community.esri.com/t5/python-questions/problems-with-field-calculator-and-python/m-p/463183#M36308</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here's a way to do it using the Calculate Field tool, with a Python dictionary -- a little easier to work with if you have more than three categories....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Calculate Field&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Expression: &lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;mph(!CFCC2!)&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Parser:&lt;/P&gt;&lt;P&gt;PYTHON&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Code Block:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;speed = {"A3":30, "A4":30, "A5":35}
def mph(code):
&amp;nbsp; return speed&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;/PRE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 20:34:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/problems-with-field-calculator-and-python/m-p/463183#M36308</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2021-12-11T20:34:21Z</dc:date>
    </item>
    <item>
      <title>Re: Problems with field Calculator and python scripting</title>
      <link>https://community.esri.com/t5/python-questions/problems-with-field-calculator-and-python/m-p/463184#M36309</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You could also set up a domain for field CFCC2 if this is in a geodatabase. Then no need for a separate Speed field. This is a more database-centric method, since having two fields essentially duplicates the same information in different display formats.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 01 Dec 2014 14:23:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/problems-with-field-calculator-and-python/m-p/463184#M36309</guid>
      <dc:creator>Zeke</dc:creator>
      <dc:date>2014-12-01T14:23:42Z</dc:date>
    </item>
  </channel>
</rss>

