[Python] observe dont enter the fuction when i change the dates

Discussão em 'Python' iniciado por Stack, Março 29, 2025.

  1. Stack

    Stack Membro Participativo

    Im working on Jupiter notebook in Visual Studio and when using the observe for entering a function when I change the dates on a datepicker the code doesnt enter the function.

    Code:

    t_datos=pd.read_excel(io='./data/SD_5Min.xlsx', sheet_name='Radiacion')
    tabla_datos=t_datos.copy()
    tabla_datos=tabla_datos.iloc[:, :3]
    tabla_datos=tabla_datos.dropna()



    date_inicial= DatePicker(
    description= "Seleccione la fecha de inicio",
    value= datetime.date(2019,8,1) #aa/mm/dd
    )

    date_final= DatePicker(
    description="Seleccione la fecha de Fin",
    value= datetime.date(2019,8,3) #aa/mm/dd
    )

    display(date_inicial)
    display(date_final)

    def df_rango_fecha(change):
    print("Funcion corriendo")
    fecha_inicial= date_inicial.value
    fecha_final= date_final.value


    fecha_i_con_hora=datetime.datetime.combine(fecha_inicial, datetime.time.min)
    fecha_f_con_hora=datetime.datetime.combine(fecha_final, datetime.time.max)


    datos_rango=tabla_datos[(tabla_datos['Date'] >= fecha_i_con_hora) & (tabla_datos['Date'] <= fecha_f_con_hora)]

    print(datos_rango)


    date_inicial.observe(df_rango_fecha , names='value')
    date_final.observe(df_rango_fecha, names='value')
    print("Código ejecutado y widgets mostrados.")


    I will be glad with some help

    Continue reading...

Compartilhe esta Página