I have a dataframe that looks like this:
Trial Measurement Data 0 0 12 1 4 2 12 1 0 12 1 12 2 0 12 1 12 2 NaN 3 12
I want to convert my data so that each test has only two dimensions. Therefore, I want to turn it into something like this:
Trial Measurement Data 0 0 8 1 8 1 0 12 1 12 2 0 12 1 12
This rather unusual task is related to the fact that my data has intentional jitter on the side of the presentation of the stimulus.
I know that pandas has a resample function, but I donβt know how to apply it to my second level index, storing data in discrete categories based on the first level index: (
Also, I wanted to iterate over my first level indices, but apparently
for sub_df in np.arange(len(df['Trial'].max()))
It does not work, since 'Trial' is an index pandas cannot find it.
python pandas time-series resampling multi-index
TheChymera Nov 20 '13 at 22:01 2013-11-20 22:01
source share