Some mock data:
test_data = [('1', '[tech, fx]'),
('2', '[industry, computer]'),
('3', '[5G, Apple]')]
test_data = spark.sparkContext.parallelize(test_data).toDF(['id', 'text'])
I wan't to create a new column that indicates if the words ['fx', 'computer'] can be found in the column called 'text':
Desired output:
result = [('1', '[tech, fx]', '1'),
('2', '[industry, computer]', '1'),
('3', '[5G, Apple]', '0')]
result = spark.sparkContext.parallelize(result).toDF(['id', 'text', 'indicator'])