Icon

05 Loops

05 Loops
Exercise: Generic LoopCreate a generic loop that checks how many nights could you stay in which room with a budget of$150:1.1) Read the New York City Airbnb data, and filter out rows where the room price is $01.2) Start a generic loop with the Generic Loop Start node1.3) Check if a room is available for 1, 2, 3, and so on nights: Create a new flow variable "nights"by adding 1 to the currentIteration flow variable. Filter the data to the rooms that are available forthis number of nights.1.4) Calculate the total price by multiplying the nights flow variable by the price per night1.5) Filter the results to rows where the total price is $150 or less 1.6) Extract the number of rows as a flow variable. Use the Extract Table Dimension node.1.7) Use the Variable Condition Loop End node to stop the loop if the number of rows is 0. Don'tcollect rows from the last iteration, but add the iteration column. How many days could you stay atmaximum for $150? 1 day Exercise: Group LoopCreate a group loop that replaces 0 prices with the average price for the same room type andneighborhood:1.1) Execute the preprepared workflow that accesses and preprocesses the New York City Airbnbdata 1.2) Start a group loop where each subgroup is defined by the neighborhood and room type1.3) Split the data into two subsets: room price=$0 and room price>$0 1.4) Calculate the average price of the rooms in the latter group1.5) Transform the average price into a flow variable1.6) Replace the $0 room prices with this flow variable value. Use the Constant Value Columnnode.1.7) Concatenate the two subsets back into one table1.8) End the loop with a Loop End node Read AB_NYC_2019dataRemove rowswith missing valuesin group columnsRead AB_NYC_2019dataprice > 0# of nights = current iteration + 1minimum nightscalculate priceper nightprice <= 150stops loop when # of rows = 0neighborhood &room typetop: price = 0bottom: price > 0average pricereplace price = 0w/ average price CSV Reader Missing Value CSV Reader Row Filter Generic Loop Start Math Formula(Variable) Row Filter Math Formula Row Filter Extract TableDimension Variable ConditionLoop End Group Loop Start Row Splitter GroupBy Table Rowto Variable ConstantValue Column Concatenate Loop End Exercise: Generic LoopCreate a generic loop that checks how many nights could you stay in which room with a budget of$150:1.1) Read the New York City Airbnb data, and filter out rows where the room price is $01.2) Start a generic loop with the Generic Loop Start node1.3) Check if a room is available for 1, 2, 3, and so on nights: Create a new flow variable "nights"by adding 1 to the currentIteration flow variable. Filter the data to the rooms that are available forthis number of nights.1.4) Calculate the total price by multiplying the nights flow variable by the price per night1.5) Filter the results to rows where the total price is $150 or less 1.6) Extract the number of rows as a flow variable. Use the Extract Table Dimension node.1.7) Use the Variable Condition Loop End node to stop the loop if the number of rows is 0. Don'tcollect rows from the last iteration, but add the iteration column. How many days could you stay atmaximum for $150? 1 day Exercise: Group LoopCreate a group loop that replaces 0 prices with the average price for the same room type andneighborhood:1.1) Execute the preprepared workflow that accesses and preprocesses the New York City Airbnbdata 1.2) Start a group loop where each subgroup is defined by the neighborhood and room type1.3) Split the data into two subsets: room price=$0 and room price>$0 1.4) Calculate the average price of the rooms in the latter group1.5) Transform the average price into a flow variable1.6) Replace the $0 room prices with this flow variable value. Use the Constant Value Columnnode.1.7) Concatenate the two subsets back into one table1.8) End the loop with a Loop End node Read AB_NYC_2019dataRemove rowswith missing valuesin group columnsRead AB_NYC_2019dataprice > 0# of nights = current iteration + 1minimum nightscalculate priceper nightprice <= 150stops loop when # of rows = 0neighborhood &room typetop: price = 0bottom: price > 0average pricereplace price = 0w/ average price CSV Reader Missing Value CSV Reader Row Filter Generic Loop Start Math Formula(Variable) Row Filter Math Formula Row Filter Extract TableDimension Variable ConditionLoop End Group Loop Start Row Splitter GroupBy Table Rowto Variable ConstantValue Column Concatenate Loop End

Nodes

Extensions

Links