pandas merge columns to create new column with comma separated values
You just need to handle NaNs
df['Colors'] = df[['Black', 'Red', 'Blue', 'Green']].apply(lambda x: ', '.join(x[x.notnull()]), axis = 1)
ID Black Red Blue Green Colors
0 120 NaN red NaN green red, green
1 121 black NaN blue NaN black, blue
Using dot
s=df.iloc[:,1:]
s.notnull()
Black Red Blue Green
0 False True False True
1 True True True False
s.notnull().dot(s.columns+',').str[:-1]
0 Red,Green
1 Black,Red,Blue
dtype: object
df['color']=s.notnull().dot(s.columns+',').str[:-1]