Icon

07 Loops

Exercise for building a loop.

Build a group loop and a counting loop.

Exercise: Group LoopThe first task is to build a group loop that compares the life expectancy in each country to the average value on the continent where it'slocated.1.1) Read the JoinedCountryTable.table file by executing the top Table Reader node. This table contains information about thedemographics, geolocation, and travel risks in the different countries/territories in 2020.1.2) Start a group loop that handles each continent in a separate iteration1.3) Build the loop body. - Calculate the average overall life expectancy on the continent- Transform the value into a flow variable- Use the Rule Engine node to assign each country the value "below" if their overall life expectancy 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. Is the life expectancy in France below or above the Europeanaverage? 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 by executing the Table Reader node2.2) Start a counting loop with 5 iterations2.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. What is the forecasted population in Chile in 2024? One iterationper rowAvg Weekly Incomeby Age Rangebelow or above theWeekly Income averageconcatenatethe results5 iterationsAdd change to currentpopulationColumn header2020 + current iterationRename column withforecasted valuesOnly forecastedvaluesRead population2019.tableNode 27 Group Loop Start GroupBy Rule Engine Loop End(deprecated) Counting Loop Start(deprecated) Math Formula String Manipulation(Variable) Math Formula(Variable) Column Rename Column Filter Table Reader(deprecated) Table Rowto Variable CSV Reader Exercise: Group LoopThe first task is to build a group loop that compares the life expectancy in each country to the average value on the continent where it'slocated.1.1) Read the JoinedCountryTable.table file by executing the top Table Reader node. This table contains information about thedemographics, geolocation, and travel risks in the different countries/territories in 2020.1.2) Start a group loop that handles each continent in a separate iteration1.3) Build the loop body. - Calculate the average overall life expectancy on the continent- Transform the value into a flow variable- Use the Rule Engine node to assign each country the value "below" if their overall life expectancy 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. Is the life expectancy in France below or above the Europeanaverage? 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 by executing the Table Reader node2.2) Start a counting loop with 5 iterations2.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. What is the forecasted population in Chile in 2024? One iterationper rowAvg Weekly Incomeby Age Rangebelow or above theWeekly Income averageconcatenatethe results5 iterationsAdd change to currentpopulationColumn header2020 + current iterationRename column withforecasted valuesOnly forecastedvaluesRead population2019.tableNode 27 Group Loop Start GroupBy Rule Engine Loop End(deprecated) Counting Loop Start(deprecated) Math Formula String Manipulation(Variable) Math Formula(Variable) Column Rename Column Filter Table Reader(deprecated) Table Rowto Variable CSV Reader

Nodes

Extensions

Links