In [1]:
import arcgis
Create an GIS object instance using the account currently logged in through ArcGIS Pro
In [2]:
gis_retail = arcgis.gis.GIS('Pro')
Create a Web GIS Item instance using the Item ID
In [3]:
trade_area_itemid = 'bf361f9081fd43a7ba57357e74ccc373'
item = arcgis.gis.Item(gis=gis_retail, itemid=trade_area_itemid)
item
Out[3]:
Since the item only contains one feature layer, get the first layer in the item, the Feature Layer we need to work with.
In [4]:
feature_layer = item.layers[0]
feature_layer
Out[4]:
Now, for this initial analysis, query to return just the attributes for the eight minute trade areas as a Feature Set.
In [5]:
feature_set = feature_layer.query(where="AREA_DESC = '0 - 8 minutes'", returnGeometry=False)
Take advantage of the df
function on the Feature set object returned from the query to convert the data to a Pandas Data Frame.
In [6]:
data_frame = feature_set.df
data_frame.head()
Out[6]:
In [7]:
field_name_independent_list = [field['name'] for field in feature_set.fields if
field['type'] != 'esriFieldTypeOID' and # we don't need the Esri object identifier field
field['name'].startswith('Shape_') == False and # exclude the Esri shape fields
field['type'] == 'esriFieldTypeDouble' and # ensure numeric, quantatative, fields are the only fields used
field['name'] != 'STORE_LAT' and # while numeric, the fields describing the location are not independent varaibles
field['name'] != 'STORE_LONG' and # while numeric, the fields describing the location are not independent varaibles
field['name'] != 'SALESVOL' # exclude the dependent variable
]
print(field_name_independent_list)
Also, save the name of the dependent variable field as well.
In [8]:
field_name_dependent = 'SALESVOL'
This is where I am now in over my head. Initially, my thought for this first stab is to create four to six store segments using SciKit learn, and identifying the defining attributes of each. This addresses the need of stores to identify store segments for customized assortment planning. Hence, although I do not know exactly how to accomplish this, I can discuss the business case quite easily.
In [ ]: