Project Details

macros2.py funtion Categorizacion()

July 19th 2023

"The dynamic path ruta_pend4 for the ""Pendientes4.xlsx"" file is defined, 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 named df_pend4. 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. The path to read the ""Sheet3"" sheet from the same file mentioned in the previous step is defined and read in a DataFrame named df_H3. A new column called ""Categorization"" is inserted into the DataFrame df_pend4. This column is inserted after the ""Times"" column. A function called categorize is defined to apply specific conditions and lookups in the DataFrame df_pend4 and assign values to the ""Categorization"" column. The categorize 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 ""Categorization"" column. The ""Pendientes4.xlsx"" file is overwritten with the modified DataFrame df_pend4, 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 Categorizacion()