I am trying to merge time-course data from different participants. I am iteratively extracting a dataframe per participant and concatenating them at the end of the loop. Before I concatenate, I would like to add the ID of my participants to an additional index.
This seems REALLY straightforward, but I was unable to find anything on this issue :(
I would like to turn this
col
0 1
1 1.1
2 NaN
Into:
col
ID 0 1
1 1.1
2 NaN
I know I could make a new index like:
multindex = [np.array(ID*len(data)),np.array(np.arange(len(data)))]
But that's inelegant without end, and - seeing as I am measuring with high frequency over half an hour - would even get kind of slow :/
I would like to mention that I have recently found my question to be a duplicate of this other question. However mine apparently has more upvotes and better answers. “Prepend” apparently doesn't seem to draw as many hits.