Commit 87fd2467 authored by kaghog's avatar kaghog
Browse files

Add specific_weekend_scenario context option for saturdays and sundays weekend scenario

parent 728a2ace
Pipeline #104319 failed with stage
......@@ -17,6 +17,7 @@ def configure(context):
context.config("random_seed", 0)
context.config("matching_minimum_observations", 20)
context.config("weekend_scenario", False)
context.config("specific_weekend_scenario", "all") # options are "all", "saturday", "sunday"
context.stage("data.microcensus.persons")
context.stage("synthesis.population.sampled")
......@@ -159,6 +160,7 @@ def parallel_statistical_matching(context, df_source, source_identifier, weight,
def execute(context):
df_mz = context.stage("data.microcensus.persons")
is_weekend_scenario = context.config("weekend_scenario")
specific_weekend_scenario = context.config("specific_weekend_scenario")
# Source are the MZ observations, for each STATPOP person, a sample is drawn from there
df_source = pd.DataFrame(df_mz[
......@@ -168,6 +170,11 @@ def execute(context):
(~is_weekend_scenario & ~df_mz["weekend"]) # and only weekday samples for a weekday
])
#If specific weekend context is needed for saturday or sunday
if (is_weekend_scenario & (specific_weekend_scenario != "all")):
df_source = pd.DataFrame(df[((specific_weekend_scenario == "saturday") & df["saturday"]) |
((specific_weekend_scenario == "sunday") & df["sunday"])])
df_population = context.stage("synthesis.population.sampled")
number_of_statpop_persons = len(np.unique(df_population["person_id"]))
number_of_statpop_households = len(np.unique(df_population["household_id"]))
......
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