Hello I have the following code and wonder how to tell python to export a pivot table with the time windows 0.5 to 1, 1 to 1.5, 1.5 to 2, 2 to 2.5 (so in 0.5 steps). At the moment the table labels 0.5 to 1 as Sec 1, 1 to 2 as Sec 2 and 2.5 to 3 to Sec 3. So it does 1.0 steps.
power_cspre=power_cspre.crop(tmin=0.5, tmax=2.5,fmin=8, fmax=12, include_tmax=True)
#power_cspre=power_cspre[0]
alpha=np.mean(power_cspre.data, axis=1) #average electrode
alpha=np.mean(alpha.data, axis=0) #average electrode
freqs=np.mean(alpha.data, axis=0) #average frequencies
timeS=power_cspre.times[0:]
data = np.dstack((timeS,freqs))
data = data.reshape(501, 2)
index=power_cspre.times[0:]
columns=['time','value']
df_data_CSplusR = pd.DataFrame(data=data , # values
index=index,
columns=columns) # 1st row as the column names
df_data_CSplusR['pptID'] = subject
df_data_CSplusR['condition'] = 'CPR'
df_data_CSplusR['shock'] = 'P'
df_data_CSplusR['memory'] = 'R'
baseline_CPR = baseline_CPR.append(pd.DataFrame(data = df_data_CSplusR), ignore_index=True)
del power_cspre, alpha,freqs, df_data_CSplusR
**#Averages values to 1 value each sec**
** baseline_CPR=baseline_CPR[baseline_CPR['time']!=0]**
** baseline_CPR['Sec']= baseline_CPR['time'].apply(np.ceil)**
** baseline_CPR_summary=pd.pivot_table(baseline_CPR,values='value',index=['pptID'],columns=['Sec'],aggfunc=np.mean)**
It probably has something to to with the definition of the variable “Sec”, I guess
Thank you
Franzi