# Shuffle one column in conditions file, and shuffle two columns together

**URL:** <https://discourse.psychopy.org/t/shuffle-one-column-in-conditions-file-and-shuffle-two-columns-together/36930>\
**Category:** Builder\
**Created:** [October 17, 2023, 11:32pm UTC](https://discourse.psychopy.org/t/shuffle-one-column-in-conditions-file-and-shuffle-two-columns-together/36930 "2023-10-17T23:32:22Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![sofiepro](https://avatars.discourse-cdn.com/v4/letter/s/45deac/32.png) [@sofiepro](https://discourse.psychopy.org/u/sofiepro)\
**Post date:** [October 17, 2023, 11:32pm UTC](https://discourse.psychopy.org/t/shuffle-one-column-in-conditions-file-and-shuffle-two-columns-together/36930/1 "2023-10-17T23:32:22Z")

</div>

Hi there!

I am trying to create an experiment for my research project and would really appreciate some help! Please be aware I’m not the most knowledgeable on python but I’m trying to learn some :))

What I’m stuck on:

- I need to shuffle one column for each participant, as well as shuffling two other columns (but keeping these two paired) - this shuffled file can then be used for the whole experiment
- I would like to shuffle column 1 (Stimulus) individually, and shuffle columns 3 & 5 together (Corroutcome & Upvaluationoutcome)
- I would like to do this so that the correct response to the Stimulus is not the same for every participant, and that the outcome is not always caused by the same response (but the fruit needs to be the same in both Corroutcome and Upvaluationoutcome, hence they need to be shuffled together)

This is the conditions file I am currently using:

 ![Screenshot 2023-10-18 at 00.21.20](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/b/2/b2dcd5e7448fcaa962f2601c5724e671ac9b7860.png)

Any help would be really appreciated as I have tried looking online quite a lot and can’t find a solution! Please let me know if anything needs to be clarified :))

Sofie

---

<div class="post-metadata">

**Author:** ![wakecarter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/wakecarter/32/5753_2.png) [@wakecarter](https://discourse.psychopy.org/u/wakecarter)\
**Post date:** [October 18, 2023, 9:30am UTC](https://discourse.psychopy.org/t/shuffle-one-column-in-conditions-file-and-shuffle-two-columns-together/36930/2 "2023-10-18T09:30:48Z")

</div>

Have a look at my independent randomisation online demo. The principle would be to preload Stimulus into a list and then use values from that list instead of the spreadsheet during the trials loop.

> [@PsychoPy Online Demos](https://discourse.psychopy.org/t/psychopy-online-demos/22319):
>
> If you have routines or experiments that are likely to be useful to others, please create a post in this thread, editing your post to add new demos so there is one post per creator. Ideally set your demos so they can be tested without consuming a credit (if you don’t have a site license) by adding a final routine that can’t end, disabling save incomplete results and adding a small number of credits. Please do not discuss the demos in this thread or create more than one post unless you have a la…

---

<div class="post-metadata">

**Author:** ![sofiepro](https://avatars.discourse-cdn.com/v4/letter/s/45deac/32.png) [@sofiepro](https://discourse.psychopy.org/u/sofiepro)\
**Post date:** [October 18, 2023, 12:58pm UTC](https://discourse.psychopy.org/t/shuffle-one-column-in-conditions-file-and-shuffle-two-columns-together/36930/3 "2023-10-18T12:58:07Z")

</div>

Hi @wakecarter

Thanks for your response!

The problem is that the correct answer for each stimulus needs to be the same throughout the experiment (e.g., one individual must _always_ respond with ‘a’ to apple in order to get an outcome, another must _always_ respond with ‘b’).

Would this solution you have offered allow the correct answer to remain the same for the whole experiment, or would it use a random row from the conditions file every time it chooses a value from the stimuli list?

The same needs to happen with the outcomes - if an individual gets a cherry as an outcome when they provide the correct response to an apple, they must always get a cherry when responding correctly to the apple.

I may be overcomplicating this but it would be helpful to know your thoughts.

Thanks again,  
Sofie

---

<div class="post-metadata">

**Author:** ![wakecarter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/wakecarter/32/5753_2.png) [@wakecarter](https://discourse.psychopy.org/u/wakecarter)\
**Post date:** [October 18, 2023, 6:18pm UTC](https://discourse.psychopy.org/t/shuffle-one-column-in-conditions-file-and-shuffle-two-columns-together/36930/4 "2023-10-18T18:18:32Z")

</div>

You can have a list of lists, e.g. conditions = [[‘stimuli/apples.png’,‘a’, ‘b’],[‘stimuli/grapes.png’,‘b’, ‘a’]]

Then corrans might be conditions[trials.thisN][1] and the file is conditions[trials.thisN][0]
