I am new to Pyspark Dataframe.
I have a pyspark dataframe which has a column which contains value in below format
Col1 |
---|
a+ |
b+ |
a- |
b- |
I want to create another boolean column (Col2). Value for this column will be true if Col1 is having + in its value else it will be False.
I tried below code after research on Googleverse but it gave unexpected EOF while parsing error
DF = DF.withColumn("col2", F.when(DF.filter(DF.col1.like('+')), True).otherwise(False)
I also tried below code but that is also giving error Condition should be a column
df = DF.withColumn("col2", F.when(DF.filter("col1 like '%-%'")=="-", True).otherwise(False))
Please assist me on this