I need help framing a generic script that helps avoid the following kind of hard coding of strings. Thanks in advance!
df['Visual Labels'] = df['Visual Labels'].apply(lambda x: ','.join(map(str, x)))
df['CONTAINS_CATEGORY'] = df['CONTAINS_CATEGORY'].apply(lambda x: ','.join(map(str, x)))
df['image_CONTAINS_CATEGORY'] = df['image_CONTAINS_CATEGORY'].apply(lambda x: ','.join(map(str, x)))
# Combine features coming from text and image
df['Categories'] = df['CONTAINS_CATEGORY']+','+df['image_CONTAINS_CATEGORY']
df.drop(["CONTAINS_CATEGORY","image_CONTAINS_CATEGORY","CONTAINS_CONCEPT","image_CONTAINS_CONCEPT"],axis=1,inplace=True)
# Strip the last comma in the string included while joining two feature columns
df['Categories'] = df['Categories'].str.replace(", ",",").str.rstrip(",")