Project Details

macros2.py funtion filtroBogCO()

July 31st 2023

"The dynamic path ruta_pend4 is set for the ""Pendientes4.xlsx"" file, which will be located in the output folder corresponding to the current day within the project folder structure. The slope file ""Pendientes4.xlsx"" is read into a DataFrame called df_pend4 using the 'openpyxl' engine. The path to read the ""Sheet1"" sheet from the ""NATIONWIDE 5.0 MODIFICADA1.xlsx"" SLOPE Plantilla_ESTADO"" file is defined and read into a DataFrame named df_H1. A new column called ""Bogota Mapping Filter"" is inserted into the DataFrame df_pend4. This column is inserted after the ""Categorization"" column. A function called asignar_filtro is defined that will apply logic to determine if the ""Regional IPS Provider Branch Description"" is ""REGIONAL BOGOTA"" and will return ""YES"" or ""NO"". The asignar_filtro function is applied to each row in the DataFrame df_pend4 along the axis of the rows (axis=1) and the results are assigned to the ""Bogotá Assignment Filter"" column. A new column called ""Bogotá 2.0 Mapping Filter"" is inserted into the DataFrame df_pend4. This column is inserted after the ""Bogotá Assignment Filter"" column. A crossover is made between the df_pend4 and df_H1 DataFrames based on the column ""Branch of Establishment"" and ""BOGOTA ALLOCATION FILTER 2.0"", respectively. The values from the ""Filter Assignment"" column of df_H1 are assigned to the ""Bogotá 2.0 Assignment Filter"" column of df_pend4. The NaN values in the ""Bogotá 2.0 Assignment Filter"" column are replaced by 0. A new column called ""Reflective Allocation Filter"" is inserted into the DataFrame df_pend4. This column is inserted after the ""Bogotá 2.0 Assignment Filter"" column. A function called COriente is defined that will check certain conditions and return ""YES"" or ""NO"" based on those conditions. The COriente function is applied to each row in the DataFrame df_pend4 along the axis of the rows (axis=1) and the results are assigned to the ""Filter Allocation COriente"" column. The DataFrame df_pend4 is saved in a ""Pendientes4.xlsx"" file by overwriting the existing file, excluding the index in the Excel file. Finally, the function returns a value of 2 if executed successfully. Otherwise, it returns the error line along with an explanatory message of the error." librarys: sys, pandas, datetime, os, openpyxl

macros2.py funtion filtroBogCO()