Select to view content in your preferred language

Trying to create a feature layer from a pandas dataframe

2061
3
10-30-2020 01:47 PM
Labels (1)
AsafEvenPaz
Regular Contributor

Hi I am trying to follow the documentation to convert a dataframe into a feature collection.

Here is the code I am using: 

groups_stats_fc=gis.content.import_data(df)

import json
groups_stats_fc_dict = dict(groups_stats_fc.properties)
groups_stats_fc_json = json.dumps({"featureCollection": {"layers": [groups_stats_fc_dict]}})
groups_stats_fc_json

groups_stats_item_properties = {'title': 'AGOL Group Statistics',
'description':'AGOL Group Statistics' ,
'tags': 'arcgis ,python, api, pandas, csv',
'text':groups_stats_fc_json,
'type':'Feature Collection'}
group_stats_item = gis.content.add(groups_stats_item_properties)
group_stats_item

 

The item is created but when I try to access it nothing shows up...

Any ideas?

0 Kudos
3 Replies
by Anonymous User
Not applicable

Hi again Asaf!

I suspect there's an issue with the dataframe being passed in. Have you verified that the dataframe is valid and being imported correctly? When you call groups_stats_fc does it return <FeatureCollection>? You should also verify that groups_stats_fc_dict is valid.

Here's some more info on the import_data method: arcgis.gis module — arcgis 1.8.2 documentation 

0 Kudos
AsafEvenPaz
Regular Contributor

Joshua,

The dataframe seems to be valid.

When I call the groups_stats_fc it returns <FeatureCollection> and the groups_stats_fc_dict seems to be valid as well:

Any other ideas?

0 Kudos
DanCostello
New Contributor

In the last line, call:

 group_stats_item.publish()

 

This should make it vieweable on maps in ArcGIS Online.

0 Kudos