Create a data frame during a running experiment, save it and then use it as input for the next loop?

Is it possible to create a data frame in a running experiment (e.g. during a learning routine of an experiment where only certain ratings and stimuli are stored, e.g. stimuli with highest ratings), then save this dataframe as an Excel file and then use this Excel file as input for a following loop of the routine (only the stimuli with the highest ratings are presented again)?

I tried to create a dataframe in a Begin experiment code block (using install pandas as pd) and wanted to append the relevant information (stimuli with only the highest ratings) but this did not work.

Thank you very much!

I am not that familiar with dataframes but I often preload stimuli into lists or dicts and then have a loop that uses them instead of a spreadsheet. The nReps for the loop has to be the length of the list (or a large number if the code finishes the loop using trials.finished = True. There’s no need to write to a file and then read it in the same experiment.