I have a pandas dataframe of an experiment with multiple trials. The trials are numbered 1-12 and there are multiple rows per trial. I would like to make a column of 1s and 0s where 1 indicates where a trial begins. This is the code I have:
for i in df['Trial Start']: if df.groupby('Trial Number').head(1): i = 1 else: i = 0
I am getting the error 'ValueError: The truth value of a DataFrame is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all'
I know why I'm getting this error, but I also know there's definitely a better way to do this. Any help is appreciated.