Icon

07 Loops

07 Loops
Exercise: Group LoopThe first task is to build a group loop that compares the weekly earnings for each participant to the average weekly earnings based ontheir education level.1.1) Read the WA_American-Time-Use-Survey.csv file by executing the top CSV Reader node. This file contains information about thedemographics, employment, and various activities for 130,000+ surveyed participants.1.2) Start a group loop that handles each education level in a separate iteration1.3) Build the loop body. - Calculate the average weekly earnings for the education level.- Transform the value into a flow variable- Use the Rule Engine node to assign each participant the value "below" if their weekly earnings is below the average and the value"above" otherwise. Append a new column.1.4) Close the loop by concatenating the rows from the different iterations.1.5) Filter out unnecessary columns1.6) Join the results from the Group Loop w/ the Group By to verify accurracy of the "above"/"below" classification. Exercise: Counting LoopThe second task it to build a counting loop that forecasts the population in the next five years.2.1) Read the population2019.table file, and split the country names into a separate table by executing the Table Reader and ColumnSplitter nodes2.2) Start a counting loop with 5 iterations on the top output of the Column Splitter node2.3) Forecast the population in 2020 by adding the value in the Change column to the value in the Population (2019/07/01) columnonce. Forecast the population value in 2021 by adding it two times, and so on. Use the Math Formula node. Append a new columncalled "Forecast".2.4) Rename the Forecast column differently in each iteration: - Add the current iteration value to the year 2020. Use the Math Formula (Variable) node.- Use this flow variable to create a title, for example, "Forecasted population in 2020". Use the String Manipulation (Variable) node.- Use this flow variable to rename the Forecast column2.5) Exclude all other columns2.6) Close the loop by joining the columns from the different iterations. 2.7) Join the country names to the loop output on row ID. What is the forecasted population in Chile in 2024? 20,066,428 WA_American_Time_Use_Survey.csviterate per each educationlevelavg weekly earningsper educationlevelbelow/above weekly earningsvs avg earningsper educationconcatenatethe resultsWA_American_Time_Use_Survey.csvfilter columnsto relevant onesavg weekly earningsper educationlevelcompare weekly earningsto avg earningsper education levelage & yearfive iterationsiterationcountincrease agereplace columnnameiteration column5 additonal yearsfor age calculationonly iterationcolumn CSV Reader Group Loop Start GroupBy Table Rowto Variable Rule Engine Loop End CSV Reader Column Filter GroupBy Joiner Column Filter Counting Loop Start Math Formula(Variable) Math Formula Loop End (ColumnAppend) Column Rename String Manipulation(Variable) Joiner Column Filter Exercise: Group LoopThe first task is to build a group loop that compares the weekly earnings for each participant to the average weekly earnings based ontheir education level.1.1) Read the WA_American-Time-Use-Survey.csv file by executing the top CSV Reader node. This file contains information about thedemographics, employment, and various activities for 130,000+ surveyed participants.1.2) Start a group loop that handles each education level in a separate iteration1.3) Build the loop body. - Calculate the average weekly earnings for the education level.- Transform the value into a flow variable- Use the Rule Engine node to assign each participant the value "below" if their weekly earnings is below the average and the value"above" otherwise. Append a new column.1.4) Close the loop by concatenating the rows from the different iterations.1.5) Filter out unnecessary columns1.6) Join the results from the Group Loop w/ the Group By to verify accurracy of the "above"/"below" classification. Exercise: Counting LoopThe second task it to build a counting loop that forecasts the population in the next five years.2.1) Read the population2019.table file, and split the country names into a separate table by executing the Table Reader and ColumnSplitter nodes2.2) Start a counting loop with 5 iterations on the top output of the Column Splitter node2.3) Forecast the population in 2020 by adding the value in the Change column to the value in the Population (2019/07/01) columnonce. Forecast the population value in 2021 by adding it two times, and so on. Use the Math Formula node. Append a new columncalled "Forecast".2.4) Rename the Forecast column differently in each iteration: - Add the current iteration value to the year 2020. Use the Math Formula (Variable) node.- Use this flow variable to create a title, for example, "Forecasted population in 2020". Use the String Manipulation (Variable) node.- Use this flow variable to rename the Forecast column2.5) Exclude all other columns2.6) Close the loop by joining the columns from the different iterations. 2.7) Join the country names to the loop output on row ID. What is the forecasted population in Chile in 2024? 20,066,428 WA_American_Time_Use_Survey.csviterate per each educationlevelavg weekly earningsper educationlevelbelow/above weekly earningsvs avg earningsper educationconcatenatethe resultsWA_American_Time_Use_Survey.csvfilter columnsto relevant onesavg weekly earningsper educationlevelcompare weekly earningsto avg earningsper education levelage & yearfive iterationsiterationcountincrease agereplace columnnameiteration column5 additonal yearsfor age calculationonly iterationcolumn CSV Reader Group Loop Start GroupBy Table Rowto Variable Rule Engine Loop End CSV Reader Column Filter GroupBy Joiner Column Filter Counting Loop Start Math Formula(Variable) Math Formula Loop End (ColumnAppend) Column Rename String Manipulation(Variable) Joiner Column Filter

Nodes

Extensions

Links