I am following a tutorial at https://developers.arcgis.com/python/guide/part2-data-io-reading-data/
When I use optional parameters from the from_featureclass() method to refine return results, I don't get a subset of the dataset. The full dataset has 3886 rows x 50 columns. It does not matter if I specify the fields parameter or SQL query or where clause, it always return the full dataset:
Any recommendations?
Hi @ChenChen4
What version of the arcgis API are you using? I tested in version 2.2.0.1 and all seems to work as its should. See below in IDE and in Notebook. Maybe try a new notebook and the code below?
from arcgis import GIS
import pandas as pd
fc = r"C:\Users\glenb\Documents\Python\sedf_data\cities\cities.shp"
fcls_flds = pd.DataFrame.spatial.from_featureclass(location=fc, fields=["st"])
print(fcls_flds.shape)
>>> (3886, 2)
fcls_whr = pd.DataFrame.spatial.from_featureclass(location=fc, where_clause="st='ID' and pop_class=6")
print(fcls_whr.shape)
>>>(15, 51)
Thanks for the quick response. I tried the same code within ArcGIS Pro and it worked, but when I ran it from NB Server it didn't give me the subset.
I'll do more testing.