I’ve looked at this further, and the “key error” that you are getting is expected from the “at” function on a dataframe if a label that you have supplied is not known.
The reason you are seeing this is because of the value
1 in your
Ordinarily, when using pandas, when you create a dataframe from a list, or csv file, for example, the “index” for the dataframe will simply be an integer which effectively acts as a row number which I believe is what you were expecting.
However, in KNIME, it creates an index column containing the “row label” which is not an integer, but is instead a label “Row0”, “Row1”. This can then act as a unique row identifier regardless of future actions such as sorting, joining and filtering.
To demonstrate what I mean, take the following following input table:
In a python script, if you were to print input_table_1 in the Python Script node, you would see it looks like this:
This means that the first parameter for the at function will be one of the row labels “Row0”, “Row1” and so on, whilst the second parameter would be the column label “column1”
If you want to return the cell for a named column, using a row number (starting at row 0), the following methods could be used
# Copy input to output
output_table_1 = input_table_1.copy()
print("-- returning specific cell value:")
# To return a given cell by row number and column name, you can use one
# of the following methods:
I’ve uploaded the above example here:
python cell value in dataframe.knwf (8.0 KB)
edit: if you really want to use “at” , then the following would also work:
print("Using at and row number:"+input_table_1.at[input_table_1.index,'column1'])