Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

Can you use a (pandas) DataFrame object as a loop source?

I have a stimuli list file loaded in the pool, which contains pairs of sentences. I only ever want to show 1 of the 2 sentences in a pair to every participant, and which of the two is shown should be determined randomly for every participant.

I know that this doesn't work with selecting the file itself as a source for the loop, as the 'maxrep' constraint only works for repetition of a specific row, not of two rows that have the same value in one of their columns.

Therefore, I've tried creating an inline script near the start of the experiment, where I use the pandas function .sample() to select one of the two sentences from each pair, and write these to a new DataFrame object, but now I cannot figure out how to use this DataFrame object as a source for the experimental loop of my experiment (using [DataFrameName] as loop source doesn't work).

Now I could have the inline script write a new CSV file for every participant, load that CSV file into the pool, and then use that as the source, but that would clutter the experimental PC with a lot of CSV files, and just feels like an inelegant solution in general.

Is there a way to make this work, or otherwise an alternative solution (with just OpenSesame functions) to the sampling method required that I've overlooked?

Comments

Sign In or Register to comment.