Project Details

macros2.py funtion consolidadoasignacion()

August 1st 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 ""Consolidated"" is inserted into the DataFrame df_pend4. This column is inserted after the ""Filter Allocation Focus"" column. A function called asignar_consolidado is defined that will apply the conditions and return the corresponding value for the ""Consolidated"" column. The asignar_consolidado 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 ""Consolidated"" column. A new column called ""Mapping"" is inserted into the DataFrame df_pend4. This column is inserted after the ""Consolidated"" column. A function called asignar_asignacion is defined that will perform the assignments based on the conditions you set. The asignar_asignacion 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 ""Mapping"" column. The ""Pendientes4.xlsx"" file is updated with the changes made to the DataFrame df_pend4. 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 consolidadoasignacion()