Icon

04_​Data_​Transformation_​Solution

Data Transformation - Solution

Solution to exercise 4 for the KNIME Analytics Platform for Data Wranglers course
- Transform a data table with the Unpivot node and remove superfluous rows and columns
- Format a string value using a combination of different manipulation nodes, e.g. Cell Splitter, Row Splitter, and String Manipulation



Exercise 4: Table RestructuringIn this exercise you change data structure by unpivoting columns to rows. 1) Change the structure of the table with the online and onsite purchases so that each purchased product is in a separate rowand not the whole purchase event 1.1 Unpivot the columns that show the products ordered in one purchase event. Retain other columns in the table. 1.2 Remove rows that have missing values for the unpivoted column values 1.3 Rename "ColumnValues" column to "ProductNr" and "ShoppingNumber" to "OrderNumber" 1.4 Remove unnecessary columns "BasketSize" and "ColumnNames" 2) (optional) Format the product numbers 2.1 Split the product numbers into substrings where separated by "-" 2.2 Convert the middle part to string and padLeft with zeros to create a 3-char code 2.3 Combine the manipulated substrings back to one string, and replace the product numbers by these manipulated values Split on "-"Join informationRename "ColumnValues"and "ShoppingNumber"Filter Product = ?Remove"BasketSize" and"ColumnNames"Top: Online purchasesBottom: Product prizesconvert middle partto string,padLeft with 0 Cell Splitter String Manipulation Column Rename Unpivoting Row Filter Column Filter Read data ononline purchases String Manipulation Read cleanedcustomer information Read onsitetransactions data Exercise 4: Table RestructuringIn this exercise you change data structure by unpivoting columns to rows. 1) Change the structure of the table with the online and onsite purchases so that each purchased product is in a separate rowand not the whole purchase event 1.1 Unpivot the columns that show the products ordered in one purchase event. Retain other columns in the table. 1.2 Remove rows that have missing values for the unpivoted column values 1.3 Rename "ColumnValues" column to "ProductNr" and "ShoppingNumber" to "OrderNumber" 1.4 Remove unnecessary columns "BasketSize" and "ColumnNames" 2) (optional) Format the product numbers 2.1 Split the product numbers into substrings where separated by "-" 2.2 Convert the middle part to string and padLeft with zeros to create a 3-char code 2.3 Combine the manipulated substrings back to one string, and replace the product numbers by these manipulated values Split on "-"Join informationRename "ColumnValues"and "ShoppingNumber"Filter Product = ?Remove"BasketSize" and"ColumnNames"Top: Online purchasesBottom: Product prizesconvert middle partto string,padLeft with 0 Cell Splitter String Manipulation Column Rename Unpivoting Row Filter Column Filter Read data ononline purchases String Manipulation Read cleanedcustomer information Read onsitetransactions data

Nodes

Extensions

Links