<?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: Python Label Expression in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/python-label-expression/m-p/320960#M24955</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;ha ha, yes, very well put, Matt!&amp;nbsp; Excellent.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 01 Oct 2013 21:03:16 GMT</pubDate>
    <dc:creator>T__WayneWhitley</dc:creator>
    <dc:date>2013-10-01T21:03:16Z</dc:date>
    <item>
      <title>Python Label Expression</title>
      <link>https://community.esri.com/t5/python-questions/python-label-expression/m-p/320956#M24951</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I am trying to create one label expression that has two label options.&amp;nbsp; The first option will stack the parcel number on top of the lot number and the other option would stack the parcel number on top of deeded acreage.&amp;nbsp; The [LOTNUMBER] field, [PARCEL] field, are text fields the [DEEDACRES] is a double.&amp;nbsp; I have no python experience, did not think this expression would be this difficult to come up with.&amp;nbsp; I would appreciate any help.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;def FindLabel ( [PARCEL] , [LOTNUMBER] , [DEEDACRES] &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; if long([LOTNUMBER]) &amp;gt;1:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return "&amp;lt;CLR yellow='255'&amp;gt;" +&amp;nbsp; [PARCEL] + "&amp;lt;/CLR&amp;gt;" + '\n' + [LOTNUMBER]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; else:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return "&amp;lt;CLR yellow='255'&amp;gt;" +&amp;nbsp; [PARCEL] + "&amp;lt;/CLR&amp;gt;" + '\n' + [DEEDACRES]&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 01 Oct 2013 19:36:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-label-expression/m-p/320956#M24951</guid>
      <dc:creator>BartonGriesenauer</dc:creator>
      <dc:date>2013-10-01T19:36:39Z</dc:date>
    </item>
    <item>
      <title>Re: Python Label Expression</title>
      <link>https://community.esri.com/t5/python-questions/python-label-expression/m-p/320957#M24952</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;..at the very least, don't you have to convert the double to string?&amp;nbsp; Use 'str'&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 01 Oct 2013 19:59:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-label-expression/m-p/320957#M24952</guid>
      <dc:creator>T__WayneWhitley</dc:creator>
      <dc:date>2013-10-01T19:59:09Z</dc:date>
    </item>
    <item>
      <title>Re: Python Label Expression</title>
      <link>https://community.esri.com/t5/python-questions/python-label-expression/m-p/320958#M24953</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;...and don't forget your 'closing' formatting tags, this works fine for experimental purposes for me - could have just changed the label font to yellow instead of using text formatting tags, unless you have other label classes or something.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The below was just fiddling around to mimic the same design you had, where my ID field is numeric:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
def FindLabel ( [NAME], [ID] , [RECHAR]&amp;nbsp; ):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if long( [RECHAR].split('-')[0] )&amp;lt;=80000:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return "&amp;lt;CLR yellow='255'&amp;gt;"+ [RECHAR] + '\n' +&amp;nbsp; [NAME] + "&amp;lt;/CLR&amp;gt;" 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; elif long( [RECHAR].split('-')[0]) &amp;gt; 80000:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return "&amp;lt;CLR yellow='255'&amp;gt;"+ [NAME] + '\n' + str( [ID] ) + "&amp;lt;/CLR&amp;gt;"
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hope that helps - also when you post code (another example of text tags), it will display correctly if you select (highlight) your code section and use the hashtag symbol (#)...which simply should place the  tags in... &lt;PRE class="lia-code-sample line-numbers language-none"&gt; goes at the beginning, I think you get my drift, just reversed them here to negate the effect?&lt;/PRE&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;EDIT:&amp;nbsp; Please don't apply the '.split('-')[0]' on your code -- I did that only on my data to coerce text into a val I can use 'long' on.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Enjoy,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Wayne&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 15:14:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-label-expression/m-p/320958#M24953</guid>
      <dc:creator>T__WayneWhitley</dc:creator>
      <dc:date>2021-12-11T15:14:28Z</dc:date>
    </item>
    <item>
      <title>Re: Python Label Expression</title>
      <link>https://community.esri.com/t5/python-questions/python-label-expression/m-p/320959#M24954</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;To elaborate on what Wayne is saying, fields that are one of the numerical data types (long integer, short integer, double, float) can't be concatenated with strings (it's akin to asking the interpreter what number the letter "a" + 1 evaluates to). Use the built in str() method to convert numbers to strings and then it will be able to put them together (i.e. "a" + str(1) == "a" + "1" == "a1").&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So if the data types for [LOTNUMBER] and [DEEDACRES] are numerical, something like this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;def FindLabel ( [PARCEL] , [LOTNUMBER] , [DEEDACRES] ):
&amp;nbsp; if long([LOTNUMBER]) &amp;gt;1:
&amp;nbsp;&amp;nbsp;&amp;nbsp; return "&amp;lt;CLR yellow='255'&amp;gt;" +&amp;nbsp; [PARCEL] + "&amp;lt;/CLR&amp;gt;" + '\n' + str([LOTNUMBER])
&amp;nbsp; else:
&amp;nbsp;&amp;nbsp;&amp;nbsp; return "&amp;lt;CLR yellow='255'&amp;gt;" +&amp;nbsp; [PARCEL] + "&amp;lt;/CLR&amp;gt;" + '\n' + str([DEEDACRES])&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 15:14:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-label-expression/m-p/320959#M24954</guid>
      <dc:creator>MattSayler</dc:creator>
      <dc:date>2021-12-11T15:14:31Z</dc:date>
    </item>
    <item>
      <title>Re: Python Label Expression</title>
      <link>https://community.esri.com/t5/python-questions/python-label-expression/m-p/320960#M24955</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;ha ha, yes, very well put, Matt!&amp;nbsp; Excellent.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 01 Oct 2013 21:03:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-label-expression/m-p/320960#M24955</guid>
      <dc:creator>T__WayneWhitley</dc:creator>
      <dc:date>2013-10-01T21:03:16Z</dc:date>
    </item>
    <item>
      <title>Re: Python Label Expression</title>
      <link>https://community.esri.com/t5/python-questions/python-label-expression/m-p/320961#M24956</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;First off, thank you for all your help.&amp;nbsp; I am not even a novice at Python, so I don't think I stated my initial question very well.&amp;nbsp; I want to label the parcels that are lots one way and the metes &amp;amp; bounds parcels another way.&amp;nbsp; I want to label the parcels that are lots, the lot field is not null, as parcel stacked on top of lot number.&amp;nbsp; I want to label the parcels that are not lots, the lot field is null, as parcel stacked on top of deeded acreage.&amp;nbsp; I tried both your solutions and still the parcels that are &lt;/SPAN&gt;&lt;STRONG&gt;not lots&lt;/STRONG&gt;&lt;SPAN&gt; are not getting labelled at all.&amp;nbsp; My PARCEL and LOTNUMBER fields are text fields.&amp;nbsp; DEEDACRES is a double field.&amp;nbsp; I apologize for any confusion.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 Oct 2013 17:02:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-label-expression/m-p/320961#M24956</guid>
      <dc:creator>BartonGriesenauer</dc:creator>
      <dc:date>2013-10-02T17:02:31Z</dc:date>
    </item>
    <item>
      <title>Re: Python Label Expression</title>
      <link>https://community.esri.com/t5/python-questions/python-label-expression/m-p/320962#M24957</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;How about:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;def FindLabel ( [PARCEL] , [LOTNUMBER] , [DEEDACRES] ):
&amp;nbsp; if [LOTNUMBER].strip() == None:
&amp;nbsp;&amp;nbsp;&amp;nbsp; return "&amp;lt;CLR yellow='255'&amp;gt;" + [PARCEL] + "&amp;lt;/CLR&amp;gt;\n" + str([DEEDACRES])
&amp;nbsp; else:
&amp;nbsp;&amp;nbsp;&amp;nbsp; return "&amp;lt;CLR yellow='255'&amp;gt;" + [PARCEL] + "&amp;lt;/CLR&amp;gt;\n" + [LOTNUMBER]&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 15:14:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-label-expression/m-p/320962#M24957</guid>
      <dc:creator>MattSayler</dc:creator>
      <dc:date>2021-12-11T15:14:34Z</dc:date>
    </item>
    <item>
      <title>Re: Python Label Expression</title>
      <link>https://community.esri.com/t5/python-questions/python-label-expression/m-p/320963#M24958</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Still not labeling parcels with null lot number attributes.&amp;nbsp; I have attached a screen capture.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 Oct 2013 17:28:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-label-expression/m-p/320963#M24958</guid>
      <dc:creator>BartonGriesenauer</dc:creator>
      <dc:date>2013-10-02T17:28:38Z</dc:date>
    </item>
    <item>
      <title>Re: Python Label Expression</title>
      <link>https://community.esri.com/t5/python-questions/python-label-expression/m-p/320964#M24959</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Won't "not" work? I haven't corrected for your specific example, but what about something like:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
def FindLabel ( [contractorName] ):
&amp;nbsp; if not [contractorName]:
&amp;nbsp;&amp;nbsp;&amp;nbsp; a = "Apples"
&amp;nbsp; else:
&amp;nbsp;&amp;nbsp;&amp;nbsp; a = [contractorName]
&amp;nbsp; return a
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 15:14:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-label-expression/m-p/320964#M24959</guid>
      <dc:creator>MatthewDobson</dc:creator>
      <dc:date>2021-12-11T15:14:36Z</dc:date>
    </item>
    <item>
      <title>Re: Python Label Expression</title>
      <link>https://community.esri.com/t5/python-questions/python-label-expression/m-p/320965#M24960</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Or using 'not' ....&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
def FindLabel ( [PARCEL] , [LOTNUMBER] , [DEEDACRES] ):
&amp;nbsp; if not [LOTNUMBER]:
&amp;nbsp;&amp;nbsp;&amp;nbsp; return "&amp;lt;CLR yellow='255'&amp;gt;" + [PARCEL] + "&amp;lt;/CLR&amp;gt;\n" + str([DEEDACRES])
&amp;nbsp; else:
&amp;nbsp;&amp;nbsp;&amp;nbsp; return "&amp;lt;CLR yellow='255'&amp;gt;" + [PARCEL] + "&amp;lt;/CLR&amp;gt;\n" + [LOTNUMBER]
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 15:14:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-label-expression/m-p/320965#M24960</guid>
      <dc:creator>MatthewDobson</dc:creator>
      <dc:date>2021-12-11T15:14:39Z</dc:date>
    </item>
    <item>
      <title>Re: Python Label Expression</title>
      <link>https://community.esri.com/t5/python-questions/python-label-expression/m-p/320966#M24961</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thank you very much for your help that did it!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Oct 2013 11:11:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-label-expression/m-p/320966#M24961</guid>
      <dc:creator>BartonGriesenauer</dc:creator>
      <dc:date>2013-10-03T11:11:24Z</dc:date>
    </item>
    <item>
      <title>Re: Python Label Expression</title>
      <link>https://community.esri.com/t5/python-questions/python-label-expression/m-p/320967#M24962</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I need assistance with labeling also. I am new to Python and I may have posted this but I am going to try to get your assistance on this since I've been reading your answers to this string from Barton.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am trying to label contours that are designated as "major" which are the rounded number in the values fields--300, 350, 400, etc. and not label all of the contours. I've been in the Python mode, advanced checked in the label expression dialog box but how do I Find a label in one field and label it some value from another field? Is this possible?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Oct 2014 16:44:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-label-expression/m-p/320967#M24962</guid>
      <dc:creator>SiranErysian</dc:creator>
      <dc:date>2014-10-06T16:44:18Z</dc:date>
    </item>
    <item>
      <title>Re: Python Label Expression</title>
      <link>https://community.esri.com/t5/python-questions/python-label-expression/m-p/320968#M24963</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Siran,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To label numbers divisible by 100, use the modulo operator. In the label expression advanced box, set the parser to Python. Then use a function like below:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;def FindLabel(somefield):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if somefield % 100 == 0: return somefield&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if you want to label with a different field based on somefield:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;def FindLabel(somefield, anotherfield):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if somefield % 100 == 0: return anotherfield&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Oct 2014 20:30:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-label-expression/m-p/320968#M24963</guid>
      <dc:creator>Zeke</dc:creator>
      <dc:date>2014-10-06T20:30:26Z</dc:date>
    </item>
    <item>
      <title>Re: Python Label Expression</title>
      <link>https://community.esri.com/t5/python-questions/python-label-expression/m-p/320969#M24964</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;this did not work:&lt;/P&gt;&lt;P&gt;I used 50% since I want to label every 50' contour&lt;/P&gt;&lt;P&gt;&lt;IMG alt="" class="jive-image image-1" src="https://community.esri.com/legacyfs/online/18358_pastedImage_1.png" style="max-width: 1200px; max-height: 900px;" /&gt;&lt;/P&gt;&lt;P&gt;tried it without brackets around Contour also but it didn';t work.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Oct 2014 20:42:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-label-expression/m-p/320969#M24964</guid>
      <dc:creator>SiranErysian</dc:creator>
      <dc:date>2014-10-06T20:42:31Z</dc:date>
    </item>
    <item>
      <title>Re: Python Label Expression</title>
      <link>https://community.esri.com/t5/python-questions/python-label-expression/m-p/320970#M24965</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You're not using 50%. You're using modulo 50; the modulo operator is the % sign in Python. It's like regular division, except it gives you the remainder.&lt;/P&gt;&lt;P&gt;Primarily though, you need parentheses around the field name in the first line - def FindLabel([Contour]):&lt;/P&gt;&lt;P&gt;You also need to see whether the expression if [Contour] % 50 == 0: You left the 0 out above.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Oct 2014 12:32:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-label-expression/m-p/320970#M24965</guid>
      <dc:creator>Zeke</dc:creator>
      <dc:date>2014-10-07T12:32:27Z</dc:date>
    </item>
    <item>
      <title>Re: Python Label Expression</title>
      <link>https://community.esri.com/t5/python-questions/python-label-expression/m-p/320971#M24966</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks. I re do and be more careful next time....&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Oct 2014 15:21:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-label-expression/m-p/320971#M24966</guid>
      <dc:creator>SiranErysian</dc:creator>
      <dc:date>2014-10-07T15:21:27Z</dc:date>
    </item>
  </channel>
</rss>

