Python Script (Labs) – Execute failed: Duplicate key detected: "0"

Hello,

When running my Python script, I get the following error message:
ERROR Python Script (Labs) 5:7 Execute failed: org.knime.core.util.DuplicateKeyException: Duplicate key detected: “0”

In PyCharm the script works without problems and also the execution (“Execute script”) in the node configuration window works without problems. My guess is that there is a problem with the output table, since I call it in a function:

def main():
     ....
     complete_results = pd.concat(complete_results)
     knio.output_tables[0] = knio.write_table(complete_results)*

main()

Any ideas?
I am thankful for any help!

Christian

@Christian_Essen could it be that you might have duplicate IDs (RowIDs) in your data set. You might have to reset the data frame index within the Python node:

3 Likes

Hi Martin,

Thank you very much – tackling the duplicate IDs (RowIDs) did the trick. I did this directly in the Python script and inserted ignore_index=True.
The script now looks like this

> def main():
>      ....
>      complete_results = pd.concat(complete_results, ignore_index=True)
>      knio.output_tables[0] = knio.write_table(complete_results)
> 
> main()

Thank you again and best regards
Christian

3 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.