Even for a single workflow, frequently I prototype the workflow from a local Feature Class. Then, depending on where the data is coming from, I have to ingest data from data already in a Spatially Enabled Dataframe, a Feature Service url, a Feature Service Item ID in a Web GIS (ArcGIS Enterprise Portal or ArcGIS Online), or also possibly a
.csv file previously exported from a Spatially Enabled Dataframe. Further, many times I have to import data from different sources to combine in the same workflow, and the source can change as the project evolves.
In short, I frequently need a Spatially Enabled Dataframe from a variety of sources, and these sources frequently change. Guessing there is a very good chance I am not the only one doing this - here is my solution to this as a Gist you are more than welcome to use.
Yes, I freely concede there is not much error catching, and this does not account for all the edge cases you may encounter. Rather, this covers the common sources I am using. This though, is exactly the reason I am sharing this, so you can much more quickly extend it to cover your use cases with much less effort - hopefully!