Icon

06 Transform Data using Expression node - String Manipulation and Logic Implementation

<p><strong>Transform Data: Expression</strong></p><p>This workflow demonstrates the usage of the <strong><em>Expression</em></strong><em> </em>node for data transformation: <strong>String manipulation</strong> and <strong>logic implementation</strong>.</p><p>The objective of the workflow is to summarize the airline dataset, analyze the delayed flights, and provide route details.</p>

URL: KNIME Learning Center https://www.knime.com/learning
URL: KNIME Cheat Sheet: Building a KNIME workflow for beginners https://www.knime.com/cheat-sheets/building-knime-workflow-beginners
URL: KNIME Cheat Sheet: Data wrangling with KNIME Analytics Platform https://www.knime.com/files/data-wrangling-with-knime.pdf

String manipulation: Create "Route" column

Step 1: Click on the node to open the configuration window.

Step 2: In the "Expression 1" section, enter the following expression: $["Origin"] + "-" + $["Dest"]

This will concatenate the origin airport with the destination airport with a hyphen in between. Choose the "Append" option and name the new column ''Route''.

Step 3: Select "Apply and Execute" to append the new column to the output table.

Implement logic: Create "Status" column

Step 1: Click on the node to open the configuration window.

Step 2: In the "Expression 1" section, enter the following expression: if($["DepDelay"]>15,"Delayed","Not Delayed")

This will create a rule, where all flights with departure delay>15 will be assigned the status "Delayed"while the restof the flights wiill be labeled as "Not Delayed". Choose the "Append" option and name the new column "Status".

Step 3: Select "Apply and Execute" to append the new column to the output table.

Transform Data: Expression


This workflow demonstrates the usage of the Expression node for data transformation: String manipulation and logic implementation.

The objective of the workflow is to summarize the airline dataset, analyze the delayed flights, and provide route details.

Workflow complete!

Keep the momentum going by exploring Just KNIME It! on the Hub to challenge yourself and see how these nodes can be integrated into more complex workflows and use cases.

Create "Route" column:Origin-Destination
Expression
Read airline dataset:Airline.csv
CSV Reader
Count nr. of delayedflights by route
GroupBy
Sort by "Count of Flights"in descending order
Sorter
Visualizeoutput table
Table View
Create "Status" column: If departure delayed by > 15 mins,append status "Delayed"
Expression
Filter data todelayed flights
Row Filter
Rename aggregation columnto "Count of Flights"
Column Renamer

Nodes

Extensions

Links