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? 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_2019dataNr of nights:Current iteration+1minimumnightsCalculate price<150Table dimensionsRemove where price is 0Neighborhood androom typeTop: Price=0Replace price columnRemove rowswith missing valuesin group columnsRead AB_NYC_2019dataStop whennumber of rowsis zeroNode 90 CSV Reader Math Formula(Variable) Row Filter Math Formula Row Filter Extract TableDimension Row Filter Group Loop Start Row Splitter ConstantValue Column Concatenate Missing Value CSV Reader Variable ConditionLoop End Generic Loop Start Loop End Table Rowto Variable GroupBy 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? 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_2019dataNr of nights:Current iteration+1minimumnightsCalculate price<150Table dimensionsRemove where price is 0Neighborhood androom typeTop: Price=0Replace price columnRemove rowswith missing valuesin group columnsRead AB_NYC_2019dataStop whennumber of rowsis zeroNode 90 CSV Reader Math Formula(Variable) Row Filter Math Formula Row Filter Extract TableDimension Row Filter Group Loop Start Row Splitter ConstantValue Column Concatenate Missing Value CSV Reader Variable ConditionLoop End Generic Loop Start Loop End Table Rowto Variable GroupBy

Nodes

Extensions

Links