I am trying to create a Spatially Enabled Data Frame object from a FeatureLayer object using the ArcGIS API for python version 1.5.3 and pandas version 0.24.1. When I use web layers that don't have date fields it works fine, but as soon as it has a date field it stops working and I get the following error:
Exception: Could not load the dataset: dtype '<class 'datetime.datetime'>' not understood
I copied the code directly from the Introduction to the Spatially Enabled Data Frame guide page and just substituted the item id for one of my own web layers. Here is my code:
from arcgis import GIS gis = GIS("https://arcgis.com", ***, ***) item = gis.content.get('The item id') flayer = item.layers # create a Spatially Enabled DataFrame object sdf = pd.DataFrame.spatial.from_layer(flayer) sdf.head()
Any ideas? Has anyone else run into this problem?
There seems to be an underlying conflict between numpy and pandas... at least based on some forum crawling.
I was able to remedy the error by rolling back to pandas 0.23.4
This is a shame, especially since they deprecated the spatial dataframe and replaced it with the spatially enabled dataframe. Not only is it less idiomatic, but it produces this error (while the original SDF does not).
I ran into this issue. Oddly enough the tool I have makes edits to a service and it fails if I start with an empty service or one that does not contain a feature that was created in AGOL or Pro. Once I add a point that was created in AGOL or Pro I do not get the error anymore. Not ideal.
This issue has been fixed in the latest version of ArcGIS API for Python 1.8.3. To verify, you could create an anaconda environment using the following command:
conda create -n arcgis183 activate arcgis183 conda install -c esri arcgis
Then launch jupyter notebook in the desired directory.
code to verify:
from arcgis.gis import GIS from arcgis.features import GeoAccessor, GeoSeriesAccessor gis = GIS("https://geosaurus.maps.arcgis.com", "arcgis_python", "P@ssword123") item=gis.content.get('d15eba5e9fe54a968e272c32d8e58e1f') #item has Date field data = item.tables sdf = pd.DataFrame.spatial.from_layer(data) sdf.head()