Q:

Plotting of time-series of clinical trials

I have data from a clinical trial study that looks like this:
subject_ID Trial_ID MEASUREMENT_1 MEASUREMENT_2 MEASUREMENT_3... MEASUREMENT_101
1             1         0.13       0.12          0.09              0.23
1             2         0.11       0.13          0.089             0.2 

How can I plot this data as a timeseries with several trials of one subject in one plot?
I wanted to work with matplotlib and seaborn but any other library is okay as well.
Thanks in advance

A:

# wide to long form
df2 = df.melt(id_vars=['subject_ID','Trial_ID'],
              var_name='measurement',value_name='value')

# extract numbers from measurements so they will sort correctly on plot
df2['measurement'] = df2['measurement'].str.extract('(\d+)').astype(int)

# get Seaborn to properly interpret for hue keyword argument
df2['Trial_ID'] = df2['Trial_ID'].astype('category')

sns.lineplot(x='measurement',y='value',hue='Trial_ID',data=df2) 

Result:  

