File size: 1,052 Bytes
68d7c9d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
import pandas as pd
from utils.convert_to_excel import save_dataframe
url = r"./physical_db/physical_database.csv"
df = pd.read_csv(url)
def validate_azimuth(group):
"""
Validates the azimuth ordering within a group.
This function checks if the azimuth values are strictly increasing when there are exactly three values.
To make sure that Sector 3 is higher than Sector 2 and Sector 2 is higher than Sector 1
Args:
group (pd.DataFrame): A DataFrame group containing an 'Azimut' column.
Returns:
bool: True if the azimuth values are strictly increasing when there are exactly three values, False otherwise.
"""
azimuths = group.get("Azimut", []).values
if len(azimuths) == 3 and not (azimuths[0] < azimuths[1] < azimuths[2]):
return False
return True
# Apply validation per 'code'
azimut_verification = df.groupby("CODE").apply(lambda x: validate_azimuth(x))
df["Azimut_verification"] = df["CODE"].map(azimut_verification)
save_dataframe(df, "azimut_verification")
# print(df)
|