Esri / Esri/arcgis-python-api

GeoAccessor.from_table add parameter to avoid using TableToNumPyArray

Open
#1,733 1 comment 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Python
Stars
2.2k
Forks
1.2k
Avg merge
2h 40m
Merged PRs (30d)
2

Description

**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](https://github.com/Esri/arcgis-python-api/assets/20046591/db2d7472-0d95-46cb-9938-00a56742c516)

```python
from arcgis.features import GeoAccessor
import os
gdb_path = r""
feature_name = r""
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
```python
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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.