0

I dont know if i'm asking this question right but fell free ask more info if needed.

So i do this dataframe where i read csv file. Then i want to use the file to do another tasks. i want that df to be "active" but it seems like it dont recognise that dataframe outside of button.

def on_button_clicked(b):
    df = pd.read_csv(F"./siivous/cleanedfiles/node_{karry.value}.csv")
    with output:
        display (df)
        display(img)
        clear_output(wait=True)

So how can i make that dataframe active just click of the button. So excample i wrote print(df) it print that df.

1 Answers1

0

Your dataframe named df is declared inside of a function. If you do this you cannot access to it outside of that function.

I suggest you the check out this thread.

I hope it helped!

andexte
  • 181
  • 6
  • Please avoid “link only” answers. Can you please add a code example. At this point, this answer is more of a comment. – jkr May 06 '22 at 11:40
  • Hi! I don't think that duplicating the same code is effective. Links are the core of internet. On the other hand, I agree, my answer is more like a comment. Anyway, I think we both agree that the Asker got an answer. – andexte May 06 '22 at 11:47