Hi,
I've a problem to import data from a pandas data frame on ArcGIS OnLine.
I followed the documentation scrupulously on Accessing and creating content | ArcGIS for Developers paragraph "importing data from a pandas data frame".
But when I do:
myEvents = pd.read_excel(myXlsx)
myEvents_fc = myGis.content.import_data(myEvents)
myEvents_fc_dict = dict(myEvents_fc.properties)
myEvents_json = json.dumps(myEvents_fc_dict)
myEvents_item_properties = {'title': 'zzmcada_events_df',
'description': 'test to import pabdas dataframe',
'tags': 'zzmcada test, arcgis python api, pandas, xlsx',
'text':myEvents_json,
'type':'Feature Collection'}myEvents_item = myGis.content.add(myEvents_item_properties)
I receive a
RuntimeError: Error while analyzing Feature Collection, Feature Collection JSON doesn't have 'layers'
(Error Code: 406)
Columns data type are
eventID object
eventName object
eventPriority int64
eventPlanned bool
eventType object
eventAddress object
Latitude float64
Longitude float64
dtype: object
Can someone help me to understand what is wrong?
Many thanks
Marco
Solved! Go to Solution.
It seems the instructions is outdated or wrong at the first place. Please try this:
Replace
myEvents_json = json.dumps(myEvents_fc_dict)
With
myEvents_json = json.dumps({"featureCollection": {"layers": [dict(myEvents_fc.layer)]}})
I referenced this example:
Html table to pandas data frame to portal item | ArcGIS for Developers
It seems the instructions is outdated or wrong at the first place. Please try this:
Replace
myEvents_json = json.dumps(myEvents_fc_dict)
With
myEvents_json = json.dumps({"featureCollection": {"layers": [dict(myEvents_fc.layer)]}})
I referenced this example:
Html table to pandas data frame to portal item | ArcGIS for Developers
It works.
Thank you
Marco
If Simo's comment answered your question, please mark it correct to close out this question.