I am new to python. The code below creates a range of numerical values based on inputs from a csv data set, for each key in newprobValues. I would like to be able to identify which values were created via each arange() function, by assigning each new numerical values another value (i.e. 0, 1, 2)
Right now, all of the new numerical values are aggregated into one list, and I'm pulling numbers randomly out of that list and deleting them after use (in a psychology PsychoPy task). Data from the task is output into another csv file, and i would like to have a column of 0s, 1s, and 2s next to the column of new numerical values so that I can parse them for analysis.
for example: each value to come out of newprobValues1 = np.arange(low1_p, high1_p, step = SV) should have a second value of 1 associated it, so that I can output those values to a separate column in a csv file.
code:
newprobValues = {.17:[],
.28:[],
.54:[],
.84:[],
.96:[],
.99:[],}
for npv in newprobValues:
mu = probs.ix[(probs['DDPD']==npv),['Value']]
SV = hyperlaw(((1-npv)/npv), k_prob) #yields subjective value of one dollar at given delay
mu = float(mu['Value'])
generating_values_prob[npv] = {'mu':mu, 'SV':SV}
if mu >= 25.50:
#set desired ran
low1_p, high1_p = float(mu-(4*SV)), float(mu-.01) # -.01 is hack to prevent arange() from rounding uneven ceil() up to a fifth iteration
low2_p, high2_p = float(mu+SV), float(mu+(5*SV)-.01)
low3_p, high3_p = 20.5, 80
newprobValues1 = np.arange(low1_p, high1_p, step = SV) #generate hard values below indiff point
newprobValues2 = np.arange(low2_p, high2_p, step = SV) #generate hard values above indiff point
newprobValues3 = np.arange(low3_p, high3_p, step = 6.612)**
newprobValues[npv] = np.concatenate([newprobValues1, newprobValues2, newprobValues3])
newprobValues[npv] = np.insert(newprobValues[npv], 0, mu)
newprobValues[npv] = newprobValues[npv].tolist()
I have tried the code:
newprobValues1 = {'value': np.arange(low1_p, high1_p, step = SV), 'type': 0}
but I get a dictionary with 0 in it, when I really need 0 to be assigned to each number -- so that when I concatenate shuffle the arrays I can still identify the arange() function that generated each value
probsfor us and tell us, what output you expect for this data frame.newprobValues[npv]? You can separate the values within the data structure if you usenp.vstackinstead ofnp.concatenate. Then it should be easy to extract them later. Ismua scaler?