Select to view content in your preferred language

Option to allow null values when using to_featureclass() method on SeDFs

3216
2
01-24-2024 02:01 PM
Status: Open
KellyTaylor
Regular Contributor

The title says is all. I'd appreciate being able to maintain null values when converting a SeDF to a featureclass in a gdb. I've used pandas.fillna() with fillers like a space before, but sometimes a null value is there for a reason, and I'd prefer to leave it null.

2 Comments
Clubdebambos

Yes please. It currently exports as empty strings (for text fields). Here is a link to the issue and current feedback: github

Clubdebambos_0-1708611540566.png

 

EricErtl

I agree that this needs to be changed.  Its another instance of the tool changing values when not explicitly defined (sanitize_columns was another instance of this).  arcpy ExportFeatures/Table honors null values but its hit and miss with executing successfully.

Another workaround our team has utilized is to calculate values with the Calculate Field tool after using to_featureclass.

string_fields = [f.name for f in arcpy.ListFields(<fc>) if f.type == 'String']

for i in string_fields:
    arcpy.management.CalculateField(
    in_table=<fc>,
    field=i,
    expression=f"None if !{i}! == '' else !{i}!",
    expression_type="PYTHON3",
    code_block="",
    field_type="TEXT",
    enforce_domains="NO_ENFORCE_DOMAINS"
)