0 ×

Python Edit Variable

KNIME Python nodes version 4.1.3.v202005112253 by KNIME AG, Zurich, Switzerland

Allows executing a Python script in a local Python environment. The environment has to be configured under File → Preferences → KNIME → Python or via flow variable, as described in the KNIME Python Integration Installation Guide.
This node supports Python 2 and 3. It also allows to import Jupyter notebooks as Python modules via the knime_jupyter module that is available in the node's Python workspace.

Options

Script

Editor
The script in the editor panel in the center will be executed to generate this node's output. "Execute script" will execute the full script while "Execute selected lines" will only execute the currently selected part of the script.
The editor optionally provides autocompletion (CTRL + Space) if the Python module jedi is installed.
Flow variables
The pane on the left side of the editor panel lists the available flow variables. A double click on a flow variable will insert the corresponding identifier at the current cursor position in the editor panel.
Workspace
The pane on the right side of the editor panel is the workspace and lists the currently defined identifiers in the running Python instance. "Reset workspace" will remove the output of all past script executions.
Console
The console under the editor panel displays standard output, standard error, or other information.
Row limit (dialog)
Limits how many rows of input data are loaded into the dialog. This is useful to maintain the interactivity of script executions in the dialog when there are lots of input data. Changing this value only takes effect after resetting the node's workspace or closing and reopening the dialog.
Use Python version
Allows to choose the Python version that is used to execute the node. The available environments of the different versions can be checked and configured under File → Preferences → KNIME → Python. They can also be set via flow variable (see Flow Variables tab below).
Missing values (Integer, Long)
By default, Number (Integer) and Number (Long) columns containing missing values are converted into double in Python because double is the only numeric type that has a built-in representation for missing values (NaN). Converting longs to doubles, however, introduces imprecision. The conversion may be avoided by replacing missing values with so-called sentinel values. To convert missing values into sentinel values before script execution, check the first option. To convert sentinel values back into missing values after script execution, check the second option. Three different types of sentinel values are available: MIN_VAL (the smallest possible value for the column's data type), MAX_VAL (the largest possible value for the column's data type), or a custom integer value to be entered into the text field. The chosen sentinel value will be available as INT_SENTINEL and LONG_SENTINEL respectively, in the node's workspace.
Rows per chunk
Large tables are broken into chunks when they are transferred between Python and Java. This option controls how many rows are included in each chunk. The default value is intended for tables containing few columns having numeric types. If larger data types like images or text are transferred, a single chunk may exceed the maximum allowed buffer size. In this case lowering the value of this parameter helps getting reasonably sized chunks.

Templates

Create from editor...
Clicking on this button creates a new template based on the script in the editor panel of the script tab.
Note: User defined templates can be found in the folder: knime-workspace/.metadata/knime/sourcecode-templates/python-variables.
Remove selected
Clicking on this button removes the selected template.
Note: Templates provided by plugins cannot be removed.
Apply selected
Replaces the script in the editor panel of the script tab with the selected template.

Flow Variables

pythonVersionOption
Controls the Use Python version option above. The variable accepts either python2 or python3 as value.
python2Command
Controls which Python 2 environment is employed by this node if it is configured to use Python 2. This allows using an environment that is different from the one that is configured in the Preferences. The flow variable accepts the path to a Python start script as described in the KNIME Python Integration Installation Guide.
python3Command
Controls which Python 3 environment is employed by this node if it is configured to use Python 3. This allows using an environment that is different from the one that is configured in the Preferences. The flow variable accepts the path to a Python start script as described in the KNIME Python Integration Installation Guide.
sentinelOption
Controls the type of sentinel value. The flow variable accepts MIN_VALUE, MAX_VALUE, or CUSTOM as value. Setting this variable to CUSTOM makes the node respect the custom integer value either set in the dialog or via the sentinelValue flow variable.

Input Ports

The input variables. In the Python script they are available as dictionary under the name flow_variables.

Output Ports

The output variables contained in the variable flow_variables after the execution of the script.

Views

Standard output
The text sent by Python to the standard output during the execution of this node.
Error output
The text sent by Python to the error output during the execution of this node.

Best Friends (Incoming)

Best Friends (Outgoing)

Workflows

Installation

To use this node in KNIME, install KNIME Python Integration from the following update site:

KNIME 4.1

A zipped version of the software site can be downloaded here. Read our FAQs to get instructions about how to install nodes from a zipped update site.

Wait a sec! You want to explore and install nodes even faster? We highly recommend our NodePit for KNIME extension for your KNIME Analytics Platform.

Developers

You want to see the source code for this node? Click the following button and we’ll use our super-powers to find it for you.