The Python language block enables you to use Python language programs in a Workflow. To use the Python Language block, you must have a Python interpreter installed and configured.
The following demonstrates how the Python Language block can be used to sort an input lib_books.csv dataset that contains observations describing a range of books available from a lending library.
- Import the lib_books.csv dataset onto a Workflow using the Text File Import block.
- Expand the Code Blocks group in the Workflow palette, then click and drag a Python Language block onto the Workflow canvas.
- Click on the lib_books.csv dataset block's Output port and drag a connection towards the Input port of the Python Language block.
- Double-click the Python Language block to display the Python Editor view.
- In the Python Editor view:
- In the Outputs panel, click Add new output dataset.
- In the Python Editor, enter the following:
Output_1 = Input_1.sort_values(by=['Author'])
- Close the Python Editor view and save the configuration when prompted.
A green execution status is displayed in the Output port of the Python Language block and the new Working Dataset. The dataset contains all observations from the input lib_books dataset sorted alphanumerically using the Author column.
Other articles that might be of interest: