Commit 9bd54326 authored by Aurore Sallard's avatar Aurore Sallard
Browse files

Trying to modify secondary locations

parent 9f8454dd
Pipeline #83983 failed with stage
......@@ -74,6 +74,29 @@ def execute(context):
df_mz_trips.loc[df_mz_trips["wzweck1"] == 12, "purpose"] = "unknown" # Other
df_mz_trips.loc[df_mz_trips["wzweck1"] == 13, "purpose"] = "border" # Going out of country
df_mz_trips.loc[np.logical_and(df_mz_trips["wzweck1"] == 4, df_mz_trips["f51800a"] == 1), "purpose"] = "grocery"
df_mz_trips.loc[np.logical_and(df_mz_trips["wzweck1"] == 4, df_mz_trips["f51800a"] >= 2), "purpose"] = "other(S)"
df_mz_trips.loc[np.logical_and(df_mz_trips["wzweck1"] == 4, df_mz_trips["f51800a"] <= 0), "purpose"] = "other(S)"
df_mz_trips.loc[np.logical_and(df_mz_trips["wzweck1"] == 8, df_mz_trips["f51700_weg"] <= 0), "purpose"] = "other(L)"
df_mz_trips.loc[np.logical_and(df_mz_trips["wzweck1"] == 8, df_mz_trips["f51700_weg"] == 1), "purpose"] = "visits"
df_mz_trips.loc[np.logical_and(df_mz_trips["wzweck1"] == 8, df_mz_trips["f51700_weg"] == 2), "purpose"] = "gastronomy"
df_mz_trips.loc[np.logical_and(df_mz_trips["wzweck1"] == 8, df_mz_trips["f51700_weg"] == 3), "purpose"] = "sport"
df_mz_trips.loc[np.logical_and(df_mz_trips["wzweck1"] == 8, df_mz_trips["f51700_weg"] == 4), "purpose"] = "outdoor"
df_mz_trips.loc[np.logical_and(df_mz_trips["wzweck1"] == 8, df_mz_trips["f51700_weg"] == 5), "purpose"] = "outdoor"
df_mz_trips.loc[np.logical_and(df_mz_trips["wzweck1"] == 8, df_mz_trips["f51700_weg"] == 6), "purpose"] = "sport"
df_mz_trips.loc[np.logical_and(df_mz_trips["wzweck1"] == 8, df_mz_trips["f51700_weg"] == 7), "purpose"] = "outdoor"
df_mz_trips.loc[np.logical_and(df_mz_trips["wzweck1"] == 8, df_mz_trips["f51700_weg"] == 8), "purpose"] = "sport"
df_mz_trips.loc[np.logical_and(df_mz_trips["wzweck1"] == 8, df_mz_trips["f51700_weg"] == 9), "purpose"] = "culture"
df_mz_trips.loc[np.logical_and(df_mz_trips["wzweck1"] == 8, df_mz_trips["f51700_weg"] == 10), "purpose"] = "volunteer"
df_mz_trips.loc[np.logical_and(df_mz_trips["wzweck1"] == 8, df_mz_trips["f51700_weg"] == 11), "purpose"] = "volunteer"
df_mz_trips.loc[np.logical_and(df_mz_trips["wzweck1"] == 8, df_mz_trips["f51700_weg"] == 12), "purpose"] = "culture"
df_mz_trips.loc[np.logical_and(df_mz_trips["wzweck1"] == 8, df_mz_trips["f51700_weg"] == 13), "purpose"] = "religion"
df_mz_trips.loc[np.logical_and(df_mz_trips["wzweck1"] == 8, df_mz_trips["f51700_weg"] == 14), "purpose"] = "visits"
df_mz_trips.loc[np.logical_and(df_mz_trips["wzweck1"] == 8, df_mz_trips["f51700_weg"] == 15), "purpose"] = "outdoor"
df_mz_trips.loc[np.logical_and(df_mz_trips["wzweck1"] == 8, df_mz_trips["f51700_weg"] == 16), "purpose"] = "other(S)"
df_mz_trips.loc[np.logical_and(df_mz_trips["wzweck1"] == 8, df_mz_trips["f51700_weg"] >= 17), "purpose"] = "other(L)"
# Adjust trips back home
df_mz_trips.loc[df_mz_trips["wzweck2"] > 1, "purpose"] = "home"
......
......@@ -17,18 +17,56 @@ def execute(context):
# 85 = education
df.loc[:, "offers_education"] = df["noga"].str.startswith("85")
df.loc[df["noga"].str.startswith("85"), "education_type"] = "diverse"
df.loc[df["noga"].str.startswith("851"), "education_type"] = "kindergarten"
df.loc[df["noga"].str.startswith("852"), "education_type"] = "primary"
df.loc[df["noga"] == "853101", "education_type"] = "secondary1"
df.loc[df["noga"] == "853102", "education_type"] = "secondary2"
df.loc[df["noga"] == "853103", "education_type"] = "secondary2"
df.loc[df["noga"] == "853200", "education_type"] = "secondary2"
df.loc[df["noga"].str.startswith("854"), "education_type"] = "tertiary"
df["education_type"] = df["education_type"].astype("category")
# 90 = arts, entertainment, leisure; 56 = gastronomy
df.loc[:, "offers_leisure"] = df["noga"].str.startswith("90") | df[
"noga"].str.startswith("56")
"noga"].str.startswith("56") | df["noga"].str.startswith("91") | df["noga"].str.startswith("55") | df["noga"].str.startswith("94")
df.loc[df["noga"].str.startswith("90"), "leisure_type"] = "culture"
df.loc[df["noga"].str.startswith("91"), "leisure_type"] = "culture"
df.loc[df["noga"] == "591400", "leisure_type"] = "culture"
df.loc[df["noga"] == "920000", "leisure_type"] = "culture"
df.loc[df["noga"] == "855200", "leisure_type"] = "culture"
df.loc[df["noga"] == "932100", "leisure_type"] = "culture"
df.loc[df["noga"] == "932900", "leisure_type"] = "culture"
df.loc[df["noga"].str.startswith("55"), "leisure_type"] = "gastronomy"
df.loc[df["noga"].str.startswith("56"), "leisure_type"] = "gastronomy"
df.loc[df["noga"].str.startswith("94"), "leisure_type"] = "religion"
df.loc[df["noga"] == "855100", "leisure_type"] = "sport"
df.loc[df["noga"].str.startswith("931"), "leisure_type"] = "sport"
df["leisure_type"] = df["leisure_type"].astype("category")
# 47 = retail
df.loc[:, "offers_shop"] = df["noga"].str.startswith("47")
df.loc[df["noga"].str.startswith("47"), "shop_type"] = "diverse"
df.loc[df["noga"].str.startswith("471"), "shop_type"] = "grocery"
df.loc[df["noga"].str.startswith("472"), "shop_type"] = "grocery"
df.loc[df["noga"].str.startswith("473"), "shop_type"] = "grocery"
df.loc[df["noga"] == "478100", "shop_type"] = "grocery"
df.loc[df["noga"].str.startswith("474"), "shop_type"] = "diverse"
df.loc[df["noga"].str.startswith("475"), "shop_type"] = "diverse"
df.loc[df["noga"].str.startswith("476"), "shop_type"] = "diverse"
df.loc[df["noga"].str.startswith("477"), "shop_type"] = "diverse"
df.loc[df["noga"].str.startswith("478"), "shop_type"] = "diverse"
df.loc[df["noga"].str.startswith("479"), "shop_type"] = "diverse"
df.loc[df["noga"] == "821902", "shop_type"] = "diverse"
df.loc[df["noga"] == "451102", "shop_type"] = "diverse"
df.loc[df["noga"] == "453200", "shop_type"] = "diverse"
df.loc[df["noga"] == "454000", "shop_type"] = "diverse"
df["shop_type"] = df["shop_type"].astype("category")
del df["noga"]
df = spatial_utils.to_gpd(context, df, x="destination_x", y="destination_y", coord_type="facility")
return df[["destination_id", "destination_x", "destination_y",
"offers_work", "offers_education", "offers_leisure", "offers_shop", "offers_other",
"offers_work", "offers_education", "offers_leisure", "offers_shop", "offers_other", "leisure_type", "education_type", "shop_type",
"geometry"]]
......@@ -22,7 +22,7 @@ def execute(context):
df_statent = df_statent[~df_statent["education_type"].isna()]
age_bounds = [(-np.inf, 6), (6, 12), (12, 16), (16, np.inf)]
education_types = ["kindergarten", "primary", "secondary", "tertiary"]
education_types = ["kindergarten", "primary", "secondary1", "secondary2", "tertiary"]
query_sizes = (1, 1, 5, 10)
for (lower_bound, upper_bound), type, query_size in zip(age_bounds, education_types, query_sizes):
......
......@@ -48,13 +48,24 @@ def prepare_destinations(context):
data = {}
for purpose in ("shop", "leisure", "other"):
f = df_destinations["offers_%s" % purpose].values
data[purpose] = dict(
identifiers=identifiers[f],
locations=locations[f]
)
#for purpose in ("shop", "leisure", "other"):
act_types = {"grocery": "shop_type", "diverse": "shop_type",
"culture": "leisure_type", "gastronomy": "leisure_type", "religion": "leisure_type", "sport": "leisure_type"}
for purpose in ("grocery", "diverse", "culture", "gastronomy", "religion", "sport", "other"):
if purpose == "other":
f = df_destinations["offers_%s" % purpose].values
data[purpose] = dict(
identifiers=identifiers[f],
locations=locations[f]
)
else:
f = df_destinations[act_types[purpose]].values
data[purpose] = dict(
identifiers=identifiers[f],
locations=locations[f]
)
return data
......
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