API for Python - ArcGIS pro versions 3.0 versus 3.1.x - edit_features

03-18-2024 07:19 PM
Occasional Contributor III


We have geoprocessing script tools to run in ArcGIS Pro for updating AGOL hosted feature layer attributes and downloading to local file geodatabases.

We have been working to switch the python code from arcpy to the API for Python. 

In the process, I can run the script tools fine on my machine but I'm seeing differences for some of the biologists that need to run the same tools that are getting errors.

For instance, in line 13 below this line works fine on 2 out of 4 users machines, but on one of them they are using ArcGIS Pro 3.1.x and continue to get the ValueError ("StringArray requires a sequence of strings or pandas.NA")



if arcpy.Exists(in_track_ln_fc):
    arcpy.AddMessage("Updating track line fields for AKCreationDate, AKDate, Year, Management Area")
    lyr = gis.content.get('XXXXX').layers[1]
    df = lyr.query(where = "AKDate IS Null").sdf
    df['ManagementArea'] = 'XXXX'
    df['start_time'] = df['start_time']- timedelta(hours=16)
    df['end_time'] = df['end_time'] - timedelta(hours=16)
    df['AKCreationDate'] = df['start_time']- timedelta(hours=8)
    df['AKDate'] = (df['AKCreationDate'] + timedelta(days=1)).dt.strftime('%m/%d/%Y')
    df['Year'] = df['start_time'].dt.strftime('%Y')
    df['created_date'] = df['created_date']- timedelta(hours=16)
    df['last_edited_date'] = df['last_edited_date'] - timedelta(hours=16)
    lyr.edit_features(updates = df.spatial.to_featureset())



 I've checked the dataframe and it has the records to update, but I don't understand or know how to fix the error when the code runs fine on my and a coworkers machine. I have ArcGIS Pro 3.0.x still. I'm not sure on the other user.

Similarly different data but same use of the edit_features and the user is getting an error params["updates'] = json.dumps(  

Has anyone else had issues with different versions of ArcGIS Pro and the edit_features? Any insights?

Thanks in advance!,

0 Replies