[Python] Accessing output in Python HVPlot Panel for further operations (getting a variable...

Discussão em 'Python' iniciado por Stack, Fevereiro 14, 2025.

  1. Stack

    Stack Membro Participativo

    I have a Jupyter Notebook with a Pandas Dataframe using Panel for interactive controls. My desired outcome is I want to manipulate a dataframe using the controls, then I would like to see the modified dataframe, then take additional action on this dataframe in subsequent cells. The way I currently have my script constructed, this is not possible as the results are nested in either the bind or the Panel Output. How can I access variable "filtered_frame" in a subsequent call without assigning it as a global variable?

    import panel as pn
    import hvplot.pandas
    pn.extension()

    def dostuff(a):
    filtered_frame = all_the_things
    if a_opt.value != None:
    filtered_frame = filtered_frame[filtered_frame['col_y'].isin(a_opt.value)]
    return pn.Row(filtered_frame)

    a_opt = pn.widgets.RadioBoxGroup(name='a', options=[None, True, False], inline=True)

    output = pn.bind(dostuff, a=a_opt)

    component = pn.Column(a_opt, output)

    component


    TLDR - I want to be able to access variable/dataframe filtered_frame in a new Jupyter cell after action has been taken on it in the interactive panel.

    Continue reading...

Compartilhe esta Página