<?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 Notebook within ArcGIS online times out before script completes in ArcGIS Notebooks Questions</title>
    <link>https://community.esri.com/t5/arcgis-notebooks-questions/notebook-within-arcgis-online-times-out-before/m-p/1033860#M253</link>
    <description>&lt;P&gt;I have a script that pulls a fairly large vector file and performs a query on it in order to access the contents of the table so that I can run a series of calculations based on pandas. However, the dataset is so big that it takes too long to run the script, and therefore the notebook timesout before it completes. Is there a way of increasing the time before the notebook timesout, or is there a more efficient way than my code below which can be used to extract the table from a vectorfile and converting it into a pandas dataframe?&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;LU = gis.content.get("x")
Layer_LU = LU.layers
Layer_LU = LU.layers[0].query()
Layer_LU = Layer_LU.sdf

#Insert pandas operations here&lt;/LI-CODE&gt;</description>
    <pubDate>Mon, 08 Mar 2021 11:08:29 GMT</pubDate>
    <dc:creator>BenJackson</dc:creator>
    <dc:date>2021-03-08T11:08:29Z</dc:date>
    <item>
      <title>Notebook within ArcGIS online times out before script completes</title>
      <link>https://community.esri.com/t5/arcgis-notebooks-questions/notebook-within-arcgis-online-times-out-before/m-p/1033860#M253</link>
      <description>&lt;P&gt;I have a script that pulls a fairly large vector file and performs a query on it in order to access the contents of the table so that I can run a series of calculations based on pandas. However, the dataset is so big that it takes too long to run the script, and therefore the notebook timesout before it completes. Is there a way of increasing the time before the notebook timesout, or is there a more efficient way than my code below which can be used to extract the table from a vectorfile and converting it into a pandas dataframe?&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;LU = gis.content.get("x")
Layer_LU = LU.layers
Layer_LU = LU.layers[0].query()
Layer_LU = Layer_LU.sdf

#Insert pandas operations here&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 08 Mar 2021 11:08:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-notebooks-questions/notebook-within-arcgis-online-times-out-before/m-p/1033860#M253</guid>
      <dc:creator>BenJackson</dc:creator>
      <dc:date>2021-03-08T11:08:29Z</dc:date>
    </item>
    <item>
      <title>Re: Notebook within ArcGIS online times out before script completes</title>
      <link>https://community.esri.com/t5/arcgis-notebooks-questions/notebook-within-arcgis-online-times-out-before/m-p/1033952#M254</link>
      <description>&lt;P&gt;If it's a server-based service (i.e., not hosted), you should be able to raise the timeout values on the service via Server Manager under &lt;STRONG&gt;Pooling&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jcarlson_0-1615212909273.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/7805i20A74BCF7ED76A50/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jcarlson_0-1615212909273.png" alt="jcarlson_0-1615212909273.png" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;jcarlson_0-1615212909273.png&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;If it's a hosted service or you don't have admin access to the service, you might try either of the following:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;H4&gt;Limiting the &lt;STRONG&gt;Query&lt;/STRONG&gt;()&lt;/H4&gt;&lt;P&gt;There are a few parameters you can include on your query to limit the amount of data being transferred. One easy refinement is to specify only those fields which you need to work with in Pandas, using &lt;STRONG&gt;out_fields=['field1', 'field2', ...]&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;I'm assuming you &lt;EM&gt;want&lt;/EM&gt; the geometry, but a query will return results &lt;EM&gt;much&lt;/EM&gt; faster if &lt;STRONG&gt;return_geometry=False&lt;/STRONG&gt; is set.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;H4&gt;Working in Chunks&lt;/H4&gt;&lt;P&gt;A couple of other parameters worth noting on the query are &lt;STRONG&gt;result_record_count&lt;/STRONG&gt; and &lt;STRONG&gt;result_offset, &lt;/STRONG&gt;which &lt;EM&gt;must&lt;/EM&gt; be paired with &lt;STRONG&gt;return_all_records=False&lt;/STRONG&gt; in order to work. You could perform multiple queries and then merge the resulting dataframes together. It might look something like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;lyr = gis.content.get('x').layers[0]
fields = ['the', 'fields', 'you', 'need']

# Return the total number of records
record_count = lyr.query(return_count_only=True)

# Set a chunk size, adjust as needed for performance / timeout
chunk_size = 10000

# Start with an empty dataframe
out_df = pandas.DataFrame()

n = 0

# Perform chunked queries and append resulting dataframes to out_df
while n &amp;lt;= record_count:
    out_df = out_df.append(
        lyr.query(
            out_fields=fields,
            result_record_count=chunk_size,
            result_offset=n,
            return_all_records=True,
            as_df=True),
        ignore_index=True)

    n += chunk_size

out_df&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm also using &lt;STRONG&gt;as_df=True&lt;/STRONG&gt; in the query, which returns your query directly as a dataframe.&lt;/P&gt;&lt;P&gt;Use one or both methods to make your query / queries return results quicker, and hopefully you won't run into any timeouts.&lt;/P&gt;</description>
      <pubDate>Mon, 08 Mar 2021 15:06:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-notebooks-questions/notebook-within-arcgis-online-times-out-before/m-p/1033952#M254</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2021-03-08T15:06:05Z</dc:date>
    </item>
    <item>
      <title>Re: Notebook within ArcGIS online times out before script completes</title>
      <link>https://community.esri.com/t5/arcgis-notebooks-questions/notebook-within-arcgis-online-times-out-before/m-p/1035871#M261</link>
      <description>&lt;P&gt;Thank you, this is actually really useful. I don't need the geometry data so that saves a load of time processing. Everything seems to work nicely now.&lt;/P&gt;</description>
      <pubDate>Fri, 12 Mar 2021 11:42:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-notebooks-questions/notebook-within-arcgis-online-times-out-before/m-p/1035871#M261</guid>
      <dc:creator>BenJackson</dc:creator>
      <dc:date>2021-03-12T11:42:23Z</dc:date>
    </item>
    <item>
      <title>Re: Notebook within ArcGIS online times out before script completes</title>
      <link>https://community.esri.com/t5/arcgis-notebooks-questions/notebook-within-arcgis-online-times-out-before/m-p/1037791#M262</link>
      <description>&lt;P&gt;+1, great answer.&lt;/P&gt;</description>
      <pubDate>Wed, 17 Mar 2021 19:48:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-notebooks-questions/notebook-within-arcgis-online-times-out-before/m-p/1037791#M262</guid>
      <dc:creator>MikeSlattery</dc:creator>
      <dc:date>2021-03-17T19:48:38Z</dc:date>
    </item>
  </channel>
</rss>

