using arcgis 2.4.1. Developed this script a few months ago and didn't have this problem until testing it again this week, and it is now throwing this error when trying to create a featureset from an SEDF created by the GeoAccessor.
ValueError("<weakref at 0x000002874A68BA10; to 'ExtensionBlock' at 0x000002874C193DD0> is not in list")The script is over 2k lines and this problem just started happening after we republished the services with the related tables included.
lv_sdf = GeoAccessor.from_featureclass(lv_config['lv_scratch_fc_path'])
# perform column renaming, etc.
feat_set = lv_sdf.spatial.to_featureset() # to_featureset() is broken here.Has anyone else come across this before?
I'm getting the same error in a similar situation using spatial.to_featureclass(). Script worked about 6 months ago but when I tried to run it this week it threw that error.
Doesn't look like there is much traction on this but glad to know that I'm not alone and more likely a bug than code syntax. Band aid workaround is to iterate over the dataframe and construct the list of feature dictionaries. This takes either featureclass (geometry) or table (no geometry):
def convert_to_featureset(lv_sdf):
"""
helper function to convert the sdf to a list of features for the edit_feature.
.to_featureset() here is causing <weakref at 0x0000011EC04640E0; to 'ExtensionBlock' at 0x0000011EC636CCB0>
errors in arcgis 2.4.1. should be tested in newer versions of arcgis and the be re-evaluated.
"""
features = []
if "SHAPE" in [col for col in lv_sdf.columns]:
for idx, row in lv_sdf.iterrows():
# Append to features list
features.append({
"attributes": {
key: value
for key, value in row.items()
if key != 'SHAPE' and pd.notna(value)
},
"geometry": row['SHAPE'].JSON if row['SHAPE'] else None})
else:
for idx, row in lv_sdf.iterrows():
# Append to features list
features.append({"attributes": {key: value for key, value in row.items() if pd.notna(value)}})
return features