Icon

05 Loops

05 Loops - Solution
Annotations and comments
  • Exercise: Generic Loop Create 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 $0 1.2) Start a generic loop with the Generic Loop Start node 1.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 for this number of nights. 1.4) Calculate the total price by multiplying the nights flow variable by the price per night 1.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't collect rows from the last iteration, but add the iteration column. How many days could you stay at maximum for $150?
  • Exercise: Group Loop Create a group loop that replaces 0 prices with the average price for the same room type and neighborhood: 1.1) Execute the preprepared workflow that accesses and preprocesses the New York City Airbnb data 1.2) start a group loop where each subgroup is defined by the neighborhood and room type 1.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 group 1.5) Transform the average price into a flow variable 1.6) Replace the $0 room prices with this flow variable value. Use the Constant Value Column node. 1.7) Concatenate the two subsets back into one table 1.8) End the loop with a Loop End node
  • Read AB_NYC_2019

Nodes

Extensions

Links