OK, to be honest, this is a bit confusing. A few problems that I see:
First , the DataFrame.applyfunction for each column should look larger:
df.apply(lambda x: mark(x), axis=1)
so that you actually scroll through each line.
, DataFrame.apply ( ); , df, row. df, (a) , mark - (b), - :
def mark(row):
columns = get_columns_to_alter(row['Text'])
if len(columns) > 0:
row[columns] = True
return row
new_df = df.apply(lambda x: mark(x), axis=1)
- , .