arcgis module 2.0.1
Have a hosted layer in ArcGIS Online. It contains Survey123 results. I wanted to load the results as a spatially enabled dataframe using the ArcGIS API for Python, in a Notebook currently but will move to a script eventually. There are fields of type Integer in the hosted layer. Some or all of these fields contain null/empty values. I get the item using gis.content.get(), providing the item id, without issue. I then retrieve the layer, by index position 0 as there is only 1. After retrieving the layer I call (below), all per the instructions at https://developers.arcgis.com/python/guide/part2-data-io-reading-data/ .This has worked in the past on other projects with no issues.
pd.DataFrame.spatial.from_layer(my_layer)
The issue is this time I get an exception and cannot create the dataframe.
IntCastingNaNError: Cannot convert non-finite values (NA or inf) to integer
It does not appear that you can provide dtypes, or fillna, to head this issue off before it occurs. The from_layer() does not appear to accept kwargs and takes the schema of the hosted layer. After much searching for a way around I tried an open query of the layer, without any filtering etc. Just simply called
sdf = layer.query().sdf
And this works, without raising an exception.
BUT, if you pass as_df=True to query() you will get the same IntCastingNaNError I mentioned earlier.
query(as_df=True)
This seems like inconsistent behavior. Is this a bug/mishandling or expected and why? It seems like these methods should perform similarly/consistently.
Thanks