<?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: Setting DateOnly Field back to NULL in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/setting-dateonly-field-back-to-null/m-p/1397959#M9784</link>
    <description>&lt;P&gt;Well I guess you answered my question, that does get NaT in the proper place:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;{'attributes': {'OBJECTID': '1',
                'alert_enabled': '0',
                'alert_end': NaT,
                'alert_start': NaT,
                'alert_text': '',
                'alert_title': 'None'},
 'geometry': {'rings': [long list of points here that is not relevant],
              'spatialReference': {'latestWkid': 2992, 'wkid': 2992}}}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However now I'm getting a new error:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;ValueError at /alert/1
cannot convert float NaN to integer&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So it seems like the arcgis api for python is attempting to convert it to an epoch time and that obviously can't be done from a NaN or NaT...&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 19 Mar 2024 16:50:56 GMT</pubDate>
    <dc:creator>ccowin_odfw</dc:creator>
    <dc:date>2024-03-19T16:50:56Z</dc:date>
    <item>
      <title>Setting DateOnly Field back to NULL</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/setting-dateonly-field-back-to-null/m-p/1397568#M9780</link>
      <description>&lt;P&gt;Hello,&lt;BR /&gt;&lt;BR /&gt;I'm a little stuck, I'm trying to create an internal interface for a web map so that non-gis users can set alerts for a specific area, mostly for wildfires. The main data is a hosted feature so have some code that does a query based on the objectid of the row. There are two date only fields that I can't get to reset to null, I've tried setting it to None and 'NULL' which are both converted to '' in the JSON. I can't find anything in the documentation about it either.&lt;/P&gt;&lt;P&gt;Saw this post:&amp;nbsp;&lt;A href="https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/unable-to-set-date-field-to-null-through/td-p/1194194" target="_self"&gt;https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/unable-to-set-date-field-to-null-through/td-p/1194194&lt;/A&gt;, however they went from a python dictionary and converted the whole thing to JSON. I'm just copying the existing JSON and then inserting the value from a dataframe, how can I insert a JSON NULL as NULL instead of 'NULL'?&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;My update code:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;def post_to_agol(rows_to_update, object_to_update, out_fields, query_field):
    # Rows_to_update: dataframe with one row
    # object_to_update: name of the object in the layer, have a couple other 
    # tables that I update too and use this function for that too
    # out_fields: fields to get in the query, doesnt like fields with raw 
    # HTML in it so gotta kick those out
    # query_field: ObjectID for one row and a group for another that will all 
    # then be given the same data.

    object_id = rows_to_update['subdivision'][0]
    where = "{} = '{}'".format(query_field, object_id)

    agol_fields = list(out_fields.keys())
    area = object_to_update.query(where=where, out_fields=agol_fields)
    features_for_update = []

    for subdivision in area:
        feature_to_be_updated = deepcopy(subdivision)

        for agol_field, sql_field in out_fields.items():
            feature_to_be_updated.attributes[agol_field] = rows_to_update[sql_field].iloc[0]

        features_for_update.append(feature_to_be_updated)

    object_to_update.edit_features(updates=features_for_update)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;Error:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;Exception at /alert/1
Cannot perform operation. Invalid operation parameters.
'updates' parameter is invalid
Invalid esriFieldTypeDateOnly value .
(Error Code: 400)&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 18 Mar 2024 22:48:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/setting-dateonly-field-back-to-null/m-p/1397568#M9780</guid>
      <dc:creator>ccowin_odfw</dc:creator>
      <dc:date>2024-03-18T22:48:00Z</dc:date>
    </item>
    <item>
      <title>Re: Setting DateOnly Field back to NULL</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/setting-dateonly-field-back-to-null/m-p/1397641#M9781</link>
      <description>&lt;P&gt;A quick field calculator demo using numpy's NaT (not a time), pandas has one as well&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-left" image-alt="datetime.png" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/98386i72274D199E01E879/image-size/large?v=v2&amp;amp;px=999" role="button" title="datetime.png" alt="datetime.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Mar 2024 02:25:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/setting-dateonly-field-back-to-null/m-p/1397641#M9781</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2024-03-19T02:25:28Z</dc:date>
    </item>
    <item>
      <title>Re: Setting DateOnly Field back to NULL</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/setting-dateonly-field-back-to-null/m-p/1397959#M9784</link>
      <description>&lt;P&gt;Well I guess you answered my question, that does get NaT in the proper place:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;{'attributes': {'OBJECTID': '1',
                'alert_enabled': '0',
                'alert_end': NaT,
                'alert_start': NaT,
                'alert_text': '',
                'alert_title': 'None'},
 'geometry': {'rings': [long list of points here that is not relevant],
              'spatialReference': {'latestWkid': 2992, 'wkid': 2992}}}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However now I'm getting a new error:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;ValueError at /alert/1
cannot convert float NaN to integer&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So it seems like the arcgis api for python is attempting to convert it to an epoch time and that obviously can't be done from a NaN or NaT...&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Mar 2024 16:50:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/setting-dateonly-field-back-to-null/m-p/1397959#M9784</guid>
      <dc:creator>ccowin_odfw</dc:creator>
      <dc:date>2024-03-19T16:50:56Z</dc:date>
    </item>
    <item>
      <title>Re: Setting DateOnly Field back to NULL</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/setting-dateonly-field-back-to-null/m-p/1398058#M9787</link>
      <description>&lt;P&gt;There is no integer none-type like floats or time.&amp;nbsp; you have to use an old-school integer sentinel like -999&lt;/P&gt;</description>
      <pubDate>Tue, 19 Mar 2024 19:35:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/setting-dateonly-field-back-to-null/m-p/1398058#M9787</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2024-03-19T19:35:48Z</dc:date>
    </item>
    <item>
      <title>Re: Setting DateOnly Field back to NULL</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/setting-dateonly-field-back-to-null/m-p/1398067#M9788</link>
      <description>&lt;P&gt;Maybe I'm misunderstanding you, but when using -999 it doesn't give an error but it also doesn't overwrite the data.&lt;/P&gt;</description>
      <pubDate>Tue, 19 Mar 2024 20:06:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/setting-dateonly-field-back-to-null/m-p/1398067#M9788</guid>
      <dc:creator>ccowin_odfw</dc:creator>
      <dc:date>2024-03-19T20:06:39Z</dc:date>
    </item>
    <item>
      <title>Re: Setting DateOnly Field back to NULL</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/setting-dateonly-field-back-to-null/m-p/1398111#M9789</link>
      <description>&lt;P&gt;The point was...&amp;nbsp;&lt;SPAN&gt;no integer none-type&amp;nbsp;... in order to flag that there is nodata/null/nan/nat in a cell for integers in code, you would have to use the "old" method of using a number that couldn't possibly exist in it. -999 was just an example.&amp;nbsp; For 64 bit integer fields I would use&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;2^63-1(9,223,372,036,854,775,807).&amp;nbsp; Personally, I don't permit nulls in my data fields, using appropriate "sentinels" that will quickly denote something is amiss should I try to perform calculations using the data in the field.&lt;/P&gt;&lt;P&gt;But, I digress,&amp;nbsp; your 'alert ' requirements need something, and if -999 won't overwrite it, then you have to find something permissable that does&lt;/P&gt;</description>
      <pubDate>Tue, 19 Mar 2024 21:56:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/setting-dateonly-field-back-to-null/m-p/1398111#M9789</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2024-03-19T21:56:22Z</dc:date>
    </item>
  </channel>
</rss>

