I have a dataframe containing column of lists:
col_1
[A, A, A, B, C]
[D, B, C]
[C]
[A, A, A]
NaN
I want to create new column, if the list starts with 3* A return 1, if not return 0:
col_1 new_col
[A, A, A, B, C] 1
[D, B, C] 0
[C] 0
[A, A, A] 1
NaN 0
I tried this but didn't work:
df['new_col'] = df.loc[df.col_1[0:3] == [A, A, A]]
