Commit 3e8b8aed authored by kaghog's avatar kaghog
Browse files

be able to generate distance distribution for specific days

parent b3319b23
......@@ -6,6 +6,7 @@ def configure(context):
context.config("weekend_scenario", False)
context.config("specific_day_scenario", "avgworkday")
def calculate_bounds(values, bin_size):
......@@ -36,13 +37,25 @@ def calculate_bounds(values, bin_size):
def execute(context):
# Prepare data
df_persons = context.stage("data.microcensus.persons")[["person_id", "person_weight", "weekend"]].rename(
df_persons = context.stage("data.microcensus.persons")[["person_id", "person_weight", "weekend", "day"]].rename(
columns={"person_weight": "weight"})
#distance distribution for weekend scenario
is_weekend_scenario = context.config("weekend_scenario")
if is_weekend_scenario:
df_persons = df_persons[df_persons["weekend"]]
print("INFO: creating distance distribution for weekend...")
specific_day = context.config("specific_day_scenario")
is_specific_day_scenario = (specific_day != "avgworkday") & (specific_day is not None)
#note that when weekend and specific day is not specified the distribution is generated for all days of the week
if (is_specific_day_scenario & ~is_weekend_scenario):
df_persons = df_persons[df_persons["day"] == specific_day]
print("INFO: creating distance distribution for specific day specified: ", df_persons["day"].unique())
print("INFO: distance distribution is created for : ", df_persons["day"].unique())
df_trips = context.stage("data.microcensus.trips")[["person_id", "trip_id", "mode", "crowfly_distance",
"departure_time", "arrival_time", "purpose"]]
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment