Pandas DataFrames and tables Problem

3309
10
08-05-2020 12:33 AM
AlbertoCañivano
New Contributor III

I have a service published in ArcGis Online that consists of a layer and two related tables.
I have to access one of the tables to write a url and I'm using Pandas to do it. Until now it worked correctly, but now I get the following error.

item = gis.content.get("xxxxxxxxxxx")
foto = (item.tables)[1]
field_service_dataframe = pd.DataFrame.spatial.from_layer(foto)

Could not load the dataset: 'PropertyMap' instance has no attribute 'drawingInfo'

If I want to access the layer, I can create the dataframe correctly; however with a table I can't.
Is it normal that only the data of the layer can be accessed or I have something missing in my code?

Tags (3)
10 Replies
MehdiPira1
Esri Contributor

Hi Alberto Cañivano

I tested the same code with a sample feature layer and it's working fine. 

I just changed the item.tables index to 0 as I only have one related table to the feature layer.

item = gis.content.get("xxxxxxxxxxxx")
foto = (item.tables)[0]
field_service_dataframe = pd.DataFrame.spatial.from_layer(foto)
field_service_dataframe

Output:

I recommend check you feature layer first, then change the index.

you can also check the code on other feature layers to see if it throws the same error.

I hope that helps.

JohnHuillery1
Occasional Contributor

I also have this problem since upgrading to ArcGIS Pro 2.6. Layer and index are correct. Worked fine before upgrading ArcGIS Pro.

0 Kudos
AlbertoCañivano1
New Contributor II

Thank you for your answer.
I keep getting bugs when I use Pandas with a table, the funny thing is that if I want to consult a layer, I don't have any problem and it shows correctly

geometry = (item.layers)[0]
field_service_dataframe = pd.DataFrame.spatial.from_layer(geometry)
field_service_dataframe
0 Kudos
JoshuaBixby
MVP Esteemed Contributor

Alberto Cañivano‌, I tested your code snippet using ArcGIS API for Python versions 1.8.x, 1.7.x, and 1.6.x; and they all fail the same way.  So, unless you were using an old version of the API, I don't think anything in the API has changed recently that would make it stop working when it did before.

What version of the API have you been using up until recently? 

0 Kudos
JohnHuillery1
Occasional Contributor

Not OP but I had been using version 1.7.  I didn't change anything in my code bu now I get 

Could not load the dataset: 'PropertyMap' instance has no attribute 'drawingInfo'

after moving to 1.8

0 Kudos
JoshuaBixby
MVP Esteemed Contributor

It does seem to be a software defect.  I encourage you to open a case with Esri Support and/or submit an issue on Issues · Esri/arcgis-python-api · GitHub 

0 Kudos
DanielPérez_López
New Contributor III

I contacted the ESRI support team, they told me it was a bug in the program and that with the new release they would fix it.

Pandas DataFrames and tables Problem · Issue #771 · Esri/arcgis-python-api · GitHub 


In the meantime, it's still (more or less) working for one table but for another table it's not working. Also, if I make a new Notebook with the same code, it doesn't work for any table.
I'll keep an eye on the new version of the api

DanielPérez_López
New Contributor III

Hi, Joshua.
Thank you for answering.
To make the script I based on the following post:
https://community.esri.com/community/comunidad-geotec/blog/2019/10/03/agregar-la-url-de-un-adjunto-a...
The author said that instead of using a layer, it was possible to enter a table (my project is about Survey123 repeats and the relational tables I need).
I modified the code for my example and it worked perfectly (running on the ArcGis Online Notebook, in BETA version: I don't know if the BETA output to production may have been the problem).

It's true that with the previous code it seems that I can't access the table anymore (as I said before I could, and with other tables I can; even mehdi pira in his answer says that he has been able to access it.

I'm testing with

from arcgis.features import SpatialDataFrame

Introduction to the Spatial DataFrame | ArcGIS for Developers 


And it does read the tables. But there are fields in the table that do not read it (I am interested in taking the ObjectID of a table to get a value from the layer, through the relationship that is given between the two tables.

Thank you

0 Kudos
JoshuaBixby
MVP Esteemed Contributor

Since Esri deprecated the SpatialDataFrame at version 1.5, I don't think switching to it represents a long-term solution, although it is good to get you past the problem for right now.  Regarding from_layer, either the documentation is wrong or the software has a defect, that much is clear.

0 Kudos