AnsweredAssumed Answered

import Pandas DataFrame with Polyline field using Python API

Question asked by jay.gregory on Feb 10, 2017
Latest reply on Feb 27, 2017 by jay.gregory

Been playing around with the Python API.  I'm using a Pandas dataframe, to which I've added a column that has a Polyline (arcgis.geometry.Polyline class) as it's attribute.  I would like to add this dataframe to a map, but the import_data method only seems to work on dataframes with x,y or lat,long column names, and I couldn't find a way to specify the Shape field when invoking the method.  Is this possible?

 

My code, in general, looks like:

 

fc_lines =  gis.content.import_data(df_lines)

map1 = gis.map()
map1.add_layer(fc_lines)

 

df_lines is a dataframe with a column, named "Lines" that contains an arcgis.geometry.Polyline object.  At least I think it contains an object - when I print out the dataframe, that column has something like

 

{"paths": [[32.08138, 40.17111], [35.182777, 39.4016666]], "spatialReference": {"wkid": 4326}}

which is the string representation of the object. But if it's actually stored as a string, that's a different matter (and maybe why it won't work).  

 

Is there a way to do what I want using the Python API, or should I somehow export the dataframe to a feature class, if that's even possible.  

Outcomes