When I run Cell Statistics from the UI, then copy the python command from History and paste it into the Python window, it produces an error:
TypeError: CellStatistics() takes from 1 to 3 positional arguments but 4 were given.
The only modification I made to the script was changing the name of the output.
Here's the code:
arcpy.ia.CellStatistics(r"'WindSpeed\WindSpd_10_HTGL1/9/2019 6:00:00 PM';'WindSpeed\WindSpd_10_HTGL1/9/2019 12:00:00 PM';'WindSpeed\WindSpd_10_HTGL1/9/2019 6:00:00 AM';WindSpeed\WindSpd_10_HTGL1/9/2019;'WindSpeed\WindSpd_10_HTGL1/8/2019 6:00:00 PM';'WindSpeed\WindSpd_10_HTGL1/8/2019 12:00:00 PM';'WindSpeed\WindSpd_10_HTGL1/8/2019 6:00:00 AM';WindSpeed\WindSpd_10_HTGL1/8/2019;'WindSpeed\WindSpd_10_HTGL1/7/2019 6:00:00 PM';'WindSpeed\WindSpd_10_HTGL1/7/2019 12:00:00 PM';'WindSpeed\WindSpd_10_HTGL1/7/2019 6:00:00 AM';WindSpeed\WindSpd_10_HTGL1/7/2019;'WindSpeed\WindSpd_10_HTGL1/6/2019 6:00:00 PM';'WindSpeed\WindSpd_10_HTGL1/6/2019 12:00:00 PM';'WindSpeed\WindSpd_10_HTGL1/6/2019 6:00:00 AM';WindSpeed\WindSpd_10_HTGL1/10/2019", r"C:\Users\gmarcus\Documents\ArcGIS\Projects\MyProject4\MyProject4.gdb\WindSpdMaxde", "MAXIMUM", "DATA")
Why would the python that ArcGIS Pro produces cause an error? Is this yet another example of a line of python produced by ArcGIS Pro that is known to not work?
I'm aware that when copying the Python from Raster Calculator also doesn't work. It seems lame to allow a user to copy a Python snippet when it won't work. Looking at the example of Cell Statistics in the documentation, it seems like this is another example of this approach. WHY ARE YOU DOING THIS ESRI?!
Solved! Go to Solution.
As Nobbir said, both formats are supported Using tools in Python—Geoprocessing and Python | ArcGIS Desktop
We include both syntax options to support different preferences for running tools - some people prefer to think of every toolbox as a Python module, which is a more Pythonic way of executing functions - arcpy.toolbox.tool(). However we wanted to support arcpy.tool_toolbox() as well since this is the legacy syntax from the old arcgisscripting, and some people prefer to have this flat list where you do not need to know the toolbox a tool is in to access it.
Both arcpy.management.Copy(... parameters..) and arcpy.Copy_management(... parameters ...) are equally valid and interchangeable for all tools. More generic is:
There seem to be a few of these. It's been an issue for a while - with ArcMap 10.3 the function to convert a model to a python script was only useful for populating the tool names, otherwise it needed to be rewritten.
Now, similar to Gabriel's issue, Intersect has a similar problem. "Copy Python Command" returns this:
arcpy.analysis.Intersect(r"BETA_AAFC_BUP_LU2010_Poly #;V_PopCtrs_2016_Buf5k_seldis_ #", r"BETA_AAFC_BUP_LU2010_Buff", "ALL", None, "INPUT")
When what it needs is this:
arcpy.analysis.Intersect(["BETA_AAFC_BUP_LU2010_Poly", "V_PopCtrs_2016_Buf5k_seldis_"], r"BETA_AAFC_BUP_LU2010_Buff", "ALL", None, "INPUT")
For the record, this is ArcGIS Pro V2.1.1.