<?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>idea Support a pd.NA to np.nan conversion inside the `sedf.spatial.to_featurelayer()` method in ArcGIS API for Python Ideas</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-ideas/support-a-pd-na-to-np-nan-conversion-inside-the/idi-p/1266352</link>
    <description>&lt;P&gt;Support a pd.NA to np.nan/None conversion inside the `sedf.spatial.to_featurelayer()` method&lt;/P&gt;&lt;P&gt;Enhancement request:&lt;/P&gt;&lt;P&gt;Inside the .spatial.to_featurelayer() method check for pd.NA datatypes and replace them with np.nan or None to supress the error message.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Steps to recreate the problem:&lt;/P&gt;&lt;P&gt;1. creating a pandas df from a csv file will produce pd.NA values (if there are missing fields in the csv)&lt;/P&gt;&lt;P&gt;--&amp;gt; works without a problem (pd.NA is the default datatype for null values when setting specific types in pd, e.g. string)&lt;/P&gt;&lt;P&gt;2. Converting the pandas df to a spatially enabled df using arcgis python module (pd.DataFrame.spatial.from_xy())&lt;/P&gt;&lt;P&gt;--&amp;gt; works without a problem&lt;/P&gt;&lt;P&gt;3. Converting the SEDF to a hosted feature layer in AGOL produces following error message:&lt;/P&gt;&lt;P&gt;-&amp;gt; fails with error message:&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Could not insert the row because of error message: value #2 - unsupported type: NAType. Recheck your data&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Steps to solve the Problem:&lt;/P&gt;&lt;P&gt;1. Fill NAs with numpy nas&lt;/P&gt;&lt;P&gt;2. Convert numpy Nans to None&lt;/P&gt;&lt;P&gt;df.fillna(np.nan)&lt;BR /&gt;df = df.replace({np.nan: None})&amp;nbsp;&lt;/P&gt;&lt;P&gt;sedf = pd.DataFrame.spatial.from_xy(df=df, x_column='X', y_column='Y', sr=4326)&lt;BR /&gt;item = sedf.spatial.to_featurelayer("test_bug_pd_na")&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;--&amp;gt; See attached Python Notebook for a example and workaround&lt;/P&gt;</description>
    <pubDate>Fri, 10 Mar 2023 09:11:41 GMT</pubDate>
    <dc:creator>vmarquart_max-boegl</dc:creator>
    <dc:date>2023-03-10T09:11:41Z</dc:date>
    <item>
      <title>Support a pd.NA to np.nan conversion inside the `sedf.spatial.to_featurelayer()` method</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-ideas/support-a-pd-na-to-np-nan-conversion-inside-the/idi-p/1266352</link>
      <description>&lt;P&gt;Support a pd.NA to np.nan/None conversion inside the `sedf.spatial.to_featurelayer()` method&lt;/P&gt;&lt;P&gt;Enhancement request:&lt;/P&gt;&lt;P&gt;Inside the .spatial.to_featurelayer() method check for pd.NA datatypes and replace them with np.nan or None to supress the error message.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Steps to recreate the problem:&lt;/P&gt;&lt;P&gt;1. creating a pandas df from a csv file will produce pd.NA values (if there are missing fields in the csv)&lt;/P&gt;&lt;P&gt;--&amp;gt; works without a problem (pd.NA is the default datatype for null values when setting specific types in pd, e.g. string)&lt;/P&gt;&lt;P&gt;2. Converting the pandas df to a spatially enabled df using arcgis python module (pd.DataFrame.spatial.from_xy())&lt;/P&gt;&lt;P&gt;--&amp;gt; works without a problem&lt;/P&gt;&lt;P&gt;3. Converting the SEDF to a hosted feature layer in AGOL produces following error message:&lt;/P&gt;&lt;P&gt;-&amp;gt; fails with error message:&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Could not insert the row because of error message: value #2 - unsupported type: NAType. Recheck your data&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Steps to solve the Problem:&lt;/P&gt;&lt;P&gt;1. Fill NAs with numpy nas&lt;/P&gt;&lt;P&gt;2. Convert numpy Nans to None&lt;/P&gt;&lt;P&gt;df.fillna(np.nan)&lt;BR /&gt;df = df.replace({np.nan: None})&amp;nbsp;&lt;/P&gt;&lt;P&gt;sedf = pd.DataFrame.spatial.from_xy(df=df, x_column='X', y_column='Y', sr=4326)&lt;BR /&gt;item = sedf.spatial.to_featurelayer("test_bug_pd_na")&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;--&amp;gt; See attached Python Notebook for a example and workaround&lt;/P&gt;</description>
      <pubDate>Fri, 10 Mar 2023 09:11:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-ideas/support-a-pd-na-to-np-nan-conversion-inside-the/idi-p/1266352</guid>
      <dc:creator>vmarquart_max-boegl</dc:creator>
      <dc:date>2023-03-10T09:11:41Z</dc:date>
    </item>
    <item>
      <title>Re: Support a pd.NA to np.nan conversion inside the `sedf.spatial.to_featurelayer()` method</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-ideas/support-a-pd-na-to-np-nan-conversion-inside-the/idc-p/1268832#M57</link>
      <description>&lt;P&gt;I recently ran into this issue! I wanted some logging to help identify the problem records, but if that could be abstracted away from the user I'd be all for that.&lt;/P&gt;&lt;P&gt;&lt;A href="https://github.com/Esri/arcgis-python-api/issues/1494" target="_blank"&gt;https://github.com/Esri/arcgis-python-api/issues/1494&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Mar 2023 00:18:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-ideas/support-a-pd-na-to-np-nan-conversion-inside-the/idc-p/1268832#M57</guid>
      <dc:creator>feralcatcolonist</dc:creator>
      <dc:date>2023-03-17T00:18:59Z</dc:date>
    </item>
    <item>
      <title>Re: Support a pd.NA to np.nan conversion inside the `sedf.spatial.to_featurelayer()` method</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-ideas/support-a-pd-na-to-np-nan-conversion-inside-the/idc-p/1270712#M60</link>
      <description>&lt;P&gt;I am getting a similar error with NAType when trying to convert dataframe to a File geodatabase Feature Class too.&amp;nbsp; df.spatial.to_featureclass&amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;(TypeError: value #5 - unsupported type: NAType)&lt;/P&gt;&lt;P&gt;Would be nice to have options to deal with these things within the command.&lt;/P&gt;</description>
      <pubDate>Thu, 23 Mar 2023 03:30:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-ideas/support-a-pd-na-to-np-nan-conversion-inside-the/idc-p/1270712#M60</guid>
      <dc:creator>GeorgieCassar1</dc:creator>
      <dc:date>2023-03-23T03:30:38Z</dc:date>
    </item>
  </channel>
</rss>

