arcgis-python-api icon indicating copy to clipboard operation
arcgis-python-api copied to clipboard

GeoAccessor.from_table add parameter to avoid using TableToNumPyArray

Open hildermesmedeiros opened this issue 1 year ago • 0 comments
trafficstars

Is your feature request related to a problem? Please describe. It would be cool a param to avoid TableToNumPyArray or just set the default as the other way. image

from arcgis.features import GeoAccessor
import os
gdb_path = r"<path>"
feature_name = r"<featurename>"
df1 = GeoAccessor.from_table(os.path.join(gdb_path, feature_name), skip_nulls=False, null_value='')

The problem is using de search cursor would return a format with pd.NA, Int32, and so on....

Describe the solution you'd like The default to be the search cursor implementation,

Describe alternatives you've considered When using tables I`m copying the code from the GeoAccessor and putting it a function or class, like below

def arcpy_to_df(table_path: str, where: Optional[str]=None) -> Union[pd.DataFrame, None]:
    """
    ETL to load arcpy to pandas DataFrame
    :param table_path: full path to table (gdb, sde or shape)
    :param where: Optional, SQL where clause to filter data
    """

    with arcpy.da.SearchCursor(
            in_table=table_path,
            field_names="*",
            where_clause=where,
    ) as scur:
        array = [row for row in scur]
        df = pd.DataFrame(array, columns=scur.fields)
    try:
        return df.convert_dtypes()
    except Exception:
        return df

Additional context Add any other context or screenshots about the feature request here.

hildermesmedeiros avatar Dec 20 '23 16:12 hildermesmedeiros