Creating a SpatialDataFrame from a Web GIS Item
The relatively recent addition of the SpatialDataFrame object to the ArcGIS Python API was a gigantic leap forward. The SpatialDataFrame marries the common data structure used for data munging and data science, the Pandas DataFrame, with ArcGIS in a familiar (for data scientists at least) and user friendly environment, Jupyter Notebook. A perfect example if this tight integration is the ability to get from an item identifier in a Web GIS to a SpatialDataFrame in one line of code.
sdf = Item(gis, item_id).layers[0].query(out_sr={'wkid': 4326}).df
There are quite a few things going on here. To explain these steps in a slightly more interactive manner, I have created a Jupyter Notebook stored in a GitHub repo you can examine, or download and run yourself to learn more about the SpatialDataFrame.