<?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: Iterating through 7740 fileds to select and delete the fields less than certain values (rainfall data) in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/iterating-through-7740-fileds-to-select-and-delete/m-p/1183519#M64775</link>
    <description>&lt;P&gt;Thank you for your response and help!&amp;nbsp;&lt;/P&gt;&lt;P&gt;After input this lines of code I got the following error:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;delete_fields=[]
for field in fields:
    precipitation = get_maximum_field_value(table, field)
    if precipitation &amp;lt; 100:
        delete_fields.append(field)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;STRONG&gt;&lt;SPAN class=""&gt;ValueError&lt;/SPAN&gt;&lt;/STRONG&gt;: zero-size array to reduction operation maximum which has no identity&lt;/PRE&gt;&lt;P&gt;Did I do something in wrong way?&lt;/P&gt;&lt;P&gt;Attached screenshot of my attribute table, it's like this for 7459 days. Of course most of the data have zero values. (Precipitation data)&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 16 Jun 2022 14:09:35 GMT</pubDate>
    <dc:creator>HadiK</dc:creator>
    <dc:date>2022-06-16T14:09:35Z</dc:date>
    <item>
      <title>Iterating through 7740 fileds to select and delete the fields less than certain values (rainfall data)</title>
      <link>https://community.esri.com/t5/python-questions/iterating-through-7740-fileds-to-select-and-delete/m-p/1183310#M64771</link>
      <description>&lt;P&gt;I have a point data which has 7740 fields precipitation value in each column for 60 million pixels.&lt;/P&gt;&lt;P&gt;I need to get rid of the columns (Daily Data) which is the date of my attribute table those are has values less than 100 mm of precipitation, find it and delete those columns (7740) . I want to do this to lighten my data for web service.&lt;/P&gt;&lt;P&gt;I want to do it in arcpy and I'm somehow confused how to do it.&lt;/P&gt;&lt;P&gt;Could you please help me with this.&lt;/P&gt;&lt;P&gt;,,,&lt;/P&gt;&lt;P&gt;import os&lt;BR /&gt;import arcpy&lt;BR /&gt;from arcpy import env&lt;/P&gt;&lt;P&gt;table = "Test_area_cliped"&lt;BR /&gt;fields = [f.name for f in arcpy.ListFields(table)]&lt;/P&gt;&lt;P&gt;,,,&lt;/P&gt;&lt;P&gt;I got all the fields now in my code but I do not know how to done it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Jun 2022 21:03:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/iterating-through-7740-fileds-to-select-and-delete/m-p/1183310#M64771</guid>
      <dc:creator>HadiK</dc:creator>
      <dc:date>2022-06-15T21:03:44Z</dc:date>
    </item>
    <item>
      <title>Re: Iterating through 7740 fileds to select and delete the fields less than certain values (rainfall data)</title>
      <link>https://community.esri.com/t5/python-questions/iterating-through-7740-fileds-to-select-and-delete/m-p/1183385#M64772</link>
      <description>&lt;P&gt;Build a list of the fields where the &lt;SPAN&gt;precipitation&amp;nbsp;&lt;/SPAN&gt;is less than 100. There a number of tools that could do this including "Summary Statistics", but I have include a way to do this with numpy. Once you have the list of fields, pass it to the delete fields tool.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import numpy
import arcpy

def get_maximum_field_value(in_table, field_name):
    """Return the maximum value of a field in a table. Using Numpy."""
    data = arcpy.da.TableToNumPyArray(in_table, [field_name])
    return numpy.max(data[field_name])

table = "Test_area_cliped"
fields = [f.name for f in arcpy.ListFields(table)]
delete_fields=[]
for field in fields:
    precipitation = get_maximum_field_value(table, field)
    if precipitation &amp;lt; 100:
        delete_fields.append(field)

arcpy.DeleteField_management(table, delete_fields)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jun 2022 01:58:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/iterating-through-7740-fileds-to-select-and-delete/m-p/1183385#M64772</guid>
      <dc:creator>MarkBryant</dc:creator>
      <dc:date>2022-06-16T01:58:06Z</dc:date>
    </item>
    <item>
      <title>Re: Iterating through 7740 fileds to select and delete the fields less than certain values (rainfall data)</title>
      <link>https://community.esri.com/t5/python-questions/iterating-through-7740-fileds-to-select-and-delete/m-p/1183519#M64775</link>
      <description>&lt;P&gt;Thank you for your response and help!&amp;nbsp;&lt;/P&gt;&lt;P&gt;After input this lines of code I got the following error:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;delete_fields=[]
for field in fields:
    precipitation = get_maximum_field_value(table, field)
    if precipitation &amp;lt; 100:
        delete_fields.append(field)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;STRONG&gt;&lt;SPAN class=""&gt;ValueError&lt;/SPAN&gt;&lt;/STRONG&gt;: zero-size array to reduction operation maximum which has no identity&lt;/PRE&gt;&lt;P&gt;Did I do something in wrong way?&lt;/P&gt;&lt;P&gt;Attached screenshot of my attribute table, it's like this for 7459 days. Of course most of the data have zero values. (Precipitation data)&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jun 2022 14:09:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/iterating-through-7740-fileds-to-select-and-delete/m-p/1183519#M64775</guid>
      <dc:creator>HadiK</dc:creator>
      <dc:date>2022-06-16T14:09:35Z</dc:date>
    </item>
    <item>
      <title>Re: Iterating through 7740 fileds to select and delete the fields less than certain values (rainfall data)</title>
      <link>https://community.esri.com/t5/python-questions/iterating-through-7740-fileds-to-select-and-delete/m-p/1183806#M64778</link>
      <description>&lt;P&gt;The ValueError&amp;nbsp; could be raised if you have nothing but null values in a column.&lt;BR /&gt;You could try changing the function checking for the maximum value to change null values to zeros.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;def get_maximum_field_value(in_table, field_name):
    """Return the maximum value of a field in a table. Using Numpy."""
    data = arcpy.da.TableToNumPyArray(in_table, [field_name], null_value=0)
    return numpy.max(data[field_name])&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Jun 2022 04:09:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/iterating-through-7740-fileds-to-select-and-delete/m-p/1183806#M64778</guid>
      <dc:creator>MarkBryant</dc:creator>
      <dc:date>2022-06-17T04:09:16Z</dc:date>
    </item>
    <item>
      <title>Re: Iterating through 7740 fileds to select and delete the fields less than certain values (rainfall data)</title>
      <link>https://community.esri.com/t5/python-questions/iterating-through-7740-fileds-to-select-and-delete/m-p/1184045#M64779</link>
      <description>&lt;P&gt;Thank you so much for your response,&lt;/P&gt;&lt;P&gt;Seems it worked. Good. But I'm not able to apply it or display the new data?1&lt;BR /&gt;When I print field it shows me 'lon'&lt;/P&gt;&lt;P&gt;When I print fields it shows me the whole fields name only.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot_2.jpg" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/43756i0705E329DA24992E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Screenshot_2.jpg" alt="Screenshot_2.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Am I doing something wrong here?! Cause I did exactly as you said &lt;/P&gt;</description>
      <pubDate>Fri, 17 Jun 2022 20:09:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/iterating-through-7740-fileds-to-select-and-delete/m-p/1184045#M64779</guid>
      <dc:creator>HadiK</dc:creator>
      <dc:date>2022-06-17T20:09:17Z</dc:date>
    </item>
  </channel>
</rss>

