Data Processing – Python

We can’t do everything with base python. You know this, previously we imported the random package. In this lesson, we’re going to be working with a very popular python package called Pandas.

Let’s say we’ve run an experiment where we ask people about their motivation and run a dot-probe task. We’re measuring motivation on a Likert scale and we want to create a median split. The dot-probe task has valid and invalid cues, and we’re interested in the accuracy and reaction time data. The dot-probe task data is coming out in long form and we want to prepare it for statistical analysis.

The task goes like this:

FIXATION
PROBE
DOT

The bulk (if not all) of the pre-processing is going to be conducted using the pandas package. Pandas is a package that is used for data manipulation and analysis and has a lot of useful functions for us!

What we’re going to do here is recreate and data processing instructions from the cognitive psychology module but in python!

When working with files we have to create a folder to hold both our .csv file and our script (.py) file. This will be our working directory.

Download the Data Processing Lesson by clicking ‘here’! If the folder downloads as a .zip file make sure you extract it.

In the folder, there will be, three .csv files corresponding with the demographic data, “how motivated are you?” Likert scale data, and the dot-probe task data. Additionally, in the folder is three python files. One of the python files is empty, one has partial code in and one is complete code. Feel free to explore as you wish! Finally, in there are the data processing instructions from the cognitive psychology module written by the wonderful Dr. Catherine Thompson! For this challenge, we shall be recreating the steps in that guide but using python!