I have a Dataframe containing various medical measurements of different patients over a number of hours (in this example 2). For instance, the dataframe is something like this:
patientid  hour measurementx measurementy
 1          1    13.5         2030
 1          2    13.9         2013
 2          1    11.5         1890
 2          2    14.9         2009 
Now, I need to construct a new Dataframe that basically groups all measurements for each patient, which would look like this:
patientid  hour measurementx measurementy  hour  measurementx measurementy
1          1    13.5         2030          2     13.9         2013
2          1    11.5         1890          2     14.9         2009
I'm quite new to Python and i have been struggling with this simple operation, I have been trying something like this, , trying to concatenate and empty Dataframe x_binary_compact with my data x_binary
old_id = 1
for row in x_binary.itertuples(index = False):
    new_id = row[0]
    if new_id == old_id:
        pd.concat((x_binary_compact, row), axis=1)
    else:
        old_id = new_id
        pd.concat((x_binary_compact), row, axis=0)
But i get an empty Dataframe as a result, so something is not right
 
     
     
    