Thank you, curtvprice. The previous line of code had a simple bracket missing that occurred when I brought the parameter into the source code, and I completely missed it. Your assistance is greatly appreciated!
... View more
I am attempting to create an ArcGIS Pro Python toolbox and tool. The script runs successfully as a standalone in Python. But after creating the toolbox and tool, setting the parameters, and then integrating them into the source code, I am getting a Syntax Error: invalid syntax and the toolbox will not run. I am importing arcpy, pandas, and numpy. The syntax error first shows up in the first line of the following excerpt of the source code, where I am trying to set this parameter as an integer so that in my next line, it can run the aggregate function to calculate the mean. # Set data column of interest as an integer so that aggregate function of 'mean' will run
platvlsub[parameters.valueAsText] = platvlsub[parameters.valueAsText].astype(int)
# Create new dataframe of pivot table with the mean population density of communes on the Plateau
platvlmn = platvlsub.pivot_table(index='Code', margins=True, margins_name='Mean_Pop_Density', aggfunc=np.mean).round(1)
# Select just "Mean_Pop_Density" row into new dataframe
platvlpop = platvlmn.query('Code == "Mean_Pop_Density"') I thought that perhaps the first line was incorrectly written, so I commented out that line. When I do that, the syntax error simply shifts to the next line. If I comment out that line, then it goes to the next line, and so forth. Again, the error is peculiar to the ArcGIS environment since the script works in Python. The only solution I found for this elsewhere was to disable the option to run in the background, which is already set to false in this case. Other attempted workarounds were not successful (including rewriting the first line and shortening the variable names), thus the Toolbox will not run. I am running version 2.6.1 of Pro and 3.6.1 of Python.
... View more