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

Annotations and comments
  • 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 rest of 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.
  • 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.
  • Read airline dataset: Airline.csv
  • Rename aggregation column to "Count of Flights"
  • Create "Status" column: If departure delayed by > 15 mins, append status "Delayed"
  • Create "Route" column: Origin-Destination
  • Count nr. of delayed flights by route
  • Filter data to delayed flights
  • Sort by "Count of Flights" in descending order
  • Visualize output table

Nodes

Extensions

Links