Addind Synchronized checking
Browse files- queries/process_neighbors.py +37 -1
queries/process_neighbors.py
CHANGED
|
@@ -9,6 +9,7 @@ from utils.utils_vars import UtilsVars
|
|
| 9 |
ADCE_INITIAL_COLUMNS = [
|
| 10 |
"ID_BTS",
|
| 11 |
"lac_id",
|
|
|
|
| 12 |
]
|
| 13 |
|
| 14 |
ADJS_INITIAL_COLUMNS = [
|
|
@@ -18,12 +19,14 @@ ADJS_INITIAL_COLUMNS = [
|
|
| 18 |
|
| 19 |
BTS_SOURCE = [
|
| 20 |
"ID_BTS",
|
|
|
|
| 21 |
"name",
|
| 22 |
"Longitude",
|
| 23 |
"Latitude",
|
| 24 |
]
|
| 25 |
BTS_TARGET = [
|
| 26 |
"lac_id",
|
|
|
|
| 27 |
"name",
|
| 28 |
"Longitude",
|
| 29 |
"Latitude",
|
|
@@ -118,7 +121,11 @@ def process_neighbors_data(file_path: str):
|
|
| 118 |
|
| 119 |
# Rename SOURCELongitude and Latitude columns
|
| 120 |
df_adce_final.rename(
|
| 121 |
-
columns={
|
|
|
|
|
|
|
|
|
|
|
|
|
| 122 |
inplace=True,
|
| 123 |
)
|
| 124 |
|
|
@@ -131,10 +138,21 @@ def process_neighbors_data(file_path: str):
|
|
| 131 |
"lac_id": "TARGET_LAC_ID",
|
| 132 |
"Longitude": "TARGET_Longitude",
|
| 133 |
"Latitude": "TARGET_Latitude",
|
|
|
|
| 134 |
},
|
| 135 |
inplace=True,
|
| 136 |
)
|
| 137 |
df_adce_final = check_symmetry(df_adce_final)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 138 |
|
| 139 |
# create distance column
|
| 140 |
df_adce_final["distance_km"] = df_adce_final.apply(
|
|
@@ -145,6 +163,24 @@ def process_neighbors_data(file_path: str):
|
|
| 145 |
axis=1,
|
| 146 |
)
|
| 147 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 148 |
# process ADJS data
|
| 149 |
df_adjs = dfs["ADJS"]
|
| 150 |
df_adjs.columns = df_adjs.columns.str.replace(r"[ ]", "", regex=True)
|
|
|
|
| 9 |
ADCE_INITIAL_COLUMNS = [
|
| 10 |
"ID_BTS",
|
| 11 |
"lac_id",
|
| 12 |
+
"synchronized",
|
| 13 |
]
|
| 14 |
|
| 15 |
ADJS_INITIAL_COLUMNS = [
|
|
|
|
| 19 |
|
| 20 |
BTS_SOURCE = [
|
| 21 |
"ID_BTS",
|
| 22 |
+
"ID_BCF",
|
| 23 |
"name",
|
| 24 |
"Longitude",
|
| 25 |
"Latitude",
|
| 26 |
]
|
| 27 |
BTS_TARGET = [
|
| 28 |
"lac_id",
|
| 29 |
+
"ID_BCF",
|
| 30 |
"name",
|
| 31 |
"Longitude",
|
| 32 |
"Latitude",
|
|
|
|
| 121 |
|
| 122 |
# Rename SOURCELongitude and Latitude columns
|
| 123 |
df_adce_final.rename(
|
| 124 |
+
columns={
|
| 125 |
+
"Longitude": "SOURCE_Longitude",
|
| 126 |
+
"Latitude": "SOURCE_Latitude",
|
| 127 |
+
"ID_BCF": "SOURCE_ID_BCF",
|
| 128 |
+
},
|
| 129 |
inplace=True,
|
| 130 |
)
|
| 131 |
|
|
|
|
| 138 |
"lac_id": "TARGET_LAC_ID",
|
| 139 |
"Longitude": "TARGET_Longitude",
|
| 140 |
"Latitude": "TARGET_Latitude",
|
| 141 |
+
"ID_BCF": "TARGET_ID_BCF",
|
| 142 |
},
|
| 143 |
inplace=True,
|
| 144 |
)
|
| 145 |
df_adce_final = check_symmetry(df_adce_final)
|
| 146 |
+
# Add column "Sync Comment"
|
| 147 |
+
# if SOURCE_ID_BCF = TARGET_ID_BCF and synchronized = 0 the "Need synchronized" else ""
|
| 148 |
+
df_adce_final["Sync Comment"] = df_adce_final.apply(
|
| 149 |
+
lambda row: (
|
| 150 |
+
"Need synchronized"
|
| 151 |
+
if row["SOURCE_ID_BCF"] == row["TARGET_ID_BCF"] and row["synchronized"] == 0
|
| 152 |
+
else ""
|
| 153 |
+
),
|
| 154 |
+
axis=1,
|
| 155 |
+
)
|
| 156 |
|
| 157 |
# create distance column
|
| 158 |
df_adce_final["distance_km"] = df_adce_final.apply(
|
|
|
|
| 163 |
axis=1,
|
| 164 |
)
|
| 165 |
|
| 166 |
+
# create final adce
|
| 167 |
+
df_adce_final = df_adce_final[
|
| 168 |
+
[
|
| 169 |
+
"SOURCE_ID",
|
| 170 |
+
"SOURCE_NAME",
|
| 171 |
+
"SOURCE_Longitude",
|
| 172 |
+
"SOURCE_Latitude",
|
| 173 |
+
"TARGET_LAC_ID",
|
| 174 |
+
"TARGET_NAME",
|
| 175 |
+
"TARGET_Longitude",
|
| 176 |
+
"TARGET_Latitude",
|
| 177 |
+
"SYMETRIQUE",
|
| 178 |
+
"synchronized",
|
| 179 |
+
"Sync Comment",
|
| 180 |
+
"distance_km",
|
| 181 |
+
]
|
| 182 |
+
]
|
| 183 |
+
|
| 184 |
# process ADJS data
|
| 185 |
df_adjs = dfs["ADJS"]
|
| 186 |
df_adjs.columns = df_adjs.columns.str.replace(r"[ ]", "", regex=True)
|