I have made the column "Turno" on the df3 using 3 validation to classify into "Turno_PM", "Turno_AM" or "N/A", but I want to know if exist an "easies way" to reach the same result, like a "cycle for" with if/elif/else or something like that.
Here the code that I have used.
from databricks import koalas as ks
from databricks.koalas.config import set_option, reset_option
set_option("compute.ops_on_diff_frames", True)
#Turno PM
kdf.loc[(kdf['dot_agencia_origen'] == 'AGENCIA RM') & (kdf['dot_agencia_destino']!='AGENCIA RM') | (kdf['dot_agencia_origen'] == 'AGENCIA VALPARAISO') & (kdf['dot_agencia_destino']!='AGENCIA RM') & (kdf['dot_agencia_destino']!='AGENCIA VALPARAISO') | (kdf['dot_agencia_origen'] == 'AGENCIA RANCAGUA') & (kdf['dot_agencia_destino']!='AGENCIA RM') & (kdf['dot_agencia_destino']!='AGENCIA RANCAGUA'),'Turno']= 'Turno_PM'
#Turno AM
kdf.loc[(kdf['dot_agencia_origen'] == 'AGENCIA RM') & (kdf['dot_agencia_destino']=='AGENCIA RM') | (kdf['dot_agencia_origen'] == 'AGENCIA VALPARAISO') & (kdf['dot_agencia_destino']=='AGENCIA RM')|(kdf['dot_agencia_origen'] == 'AGENCIA RANCAGUA') & (kdf['dot_agencia_destino']=='AGENCIA RM'),'Turno']='Turno_AM'
#Regiones
kdf.loc[(df3['Turno'].isnull()),'Turno']='Regiones'