I have an experiment that works locally in the builder using pandas to convert a list into an array, then get the average of the entire array, and then multiply it by a variable number. The code is below - multiNum is a variable (number) that gets read in from an excel sheet.
## Begin Experiment
rt_list = []
## Begin Routine
#if the array is not empty then do the mean calculation and the multiplying calculation
rt_array = np.array(rt_list)
if len(rt_array > 0):
rt_mean = rt_array.mean()
newTime = rt_mean*multiNum
## End Routine
#add response time to the array
rt_list.append(key_resp_5.rt)
I first tried to import pandas explicitly (import pandas as np) because I was getting an error that “np” wasn’t recognized. When I tried to explicitly import pandas, it got stuck on the initializing screen. I saw in the cribsheet that pandas doesn’t work online, so then I tried to remove pandas entirely and change the code in the Begin Routine section to do mathematical computations on the list:
##Begin Routine
if len(rt_list > 0):
rt_mean = rt_list.mean()
newTime = rt_mean*multiNum
But when I try to run it, I am still stuck on the initializing screen. I can’t tell if this code will work and the frozen screen is another issue, or if the frozen initializing screen is from this code. I’ve been having trouble getting the experiment to run in JS locally, so I’ve been forced to push it to Pavlovia, put it in pilot mode, test it, take it out of pilot mode, fix an error, and repeat - so I can’t tell if the initializing screen is just some other issue related whatever is going on there, or something separate.
Essentially, I need to know how to do mathematical computations to lists, or create arrays without the use of pandas. If we can troubleshoot the frozen screen at the same time, that’s great. Thanks!