<?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: Update Hosted Feature Service; Python API Throwing an error in ArcGIS Online Questions</title>
    <link>https://community.esri.com/t5/arcgis-online-questions/update-hosted-feature-service-python-api-throwing/m-p/1004205#M37489</link>
    <description>&lt;P&gt;I had this resolved. I&amp;nbsp; dropped duplicates. Being a large file, I hadnt noticed the duplicates&lt;/P&gt;</description>
    <pubDate>Tue, 24 Nov 2020 03:43:15 GMT</pubDate>
    <dc:creator>wwnde</dc:creator>
    <dc:date>2020-11-24T03:43:15Z</dc:date>
    <item>
      <title>Update Hosted Feature Service; Python API Throwing an error</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/update-hosted-feature-service-python-api-throwing/m-p/1003883#M37474</link>
      <description>&lt;P&gt;I have two feature services. An old and new one. They serve different purposes and are regularly updated by different teams. They have some common fields but not all.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to regularly find common rows based on column key and update one of them&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Layer to be updated:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;item=gis.content.get('xxxxx')
l=item.layers[0] 
df=l.query().sdf
df.head()&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Layer to be used to update;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;item=gis.content.get('yyyyy')
l=item.layers[0] 
df2=l.query().sdf
df2.head()&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Using the python &lt;A href="https://developers.arcgis.com/python/sample-notebooks/updating-features-in-a-feature-layer/" target="_self"&gt;API CODE&lt;/A&gt; I tried the following;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;g=l.query().features
g=l.query().features
for o in overlap_rows['key']:
    # get the feature to be updated
    original_feature = [f for f in g if f.attributes['key'] == o][0]
    print(original_feature)
    feature_to_be_updated = deepcopy(original_feature)
    print(o)#print(str(original_feature))
    matching_row = df2.where(df2.key== o).dropna()
    feature_to_be_updated.attributes['Long'] = float(matching_row['Long'])
    feature_to_be_updated.attributes['Lat'] = float(matching_row['Lat'])
    features_for_update.append(feature_to_be_updated)
    features_for_update&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This results into an error;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
In  [532]:
Line 9:     feature_to_be_updated.attributes['Long'] = float(matching_row['Long'])

File C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3-clone1\lib\site-packages\pandas\core\series.py, in wrapper:
Line 112:   raise TypeError(f"cannot convert the series to {converter}")

TypeError: cannot convert the series to &amp;lt;class 'float'&amp;gt;
---------------------------------------------------------------------------&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;On investigation, I found for some reason&amp;nbsp; the line below&amp;nbsp; at time returns two rows and not one despite the fact that the key is unique for each row;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;matching_row = df2.where(df2.Ops_Code == o).dropna()&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any reasons why this is happening?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Has someone done such an update before?&lt;/P&gt;</description>
      <pubDate>Mon, 23 Nov 2020 08:36:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/update-hosted-feature-service-python-api-throwing/m-p/1003883#M37474</guid>
      <dc:creator>wwnde</dc:creator>
      <dc:date>2020-11-23T08:36:16Z</dc:date>
    </item>
    <item>
      <title>Re: Update Hosted Feature Service; Python API Throwing an error</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/update-hosted-feature-service-python-api-throwing/m-p/1004205#M37489</link>
      <description>&lt;P&gt;I had this resolved. I&amp;nbsp; dropped duplicates. Being a large file, I hadnt noticed the duplicates&lt;/P&gt;</description>
      <pubDate>Tue, 24 Nov 2020 03:43:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/update-hosted-feature-service-python-api-throwing/m-p/1004205#M37489</guid>
      <dc:creator>wwnde</dc:creator>
      <dc:date>2020-11-24T03:43:15Z</dc:date>
    </item>
  </channel>
</rss>

