1

I am new to Pyspark

I have this piece of code:

df2 = df.withColumn("VALUE", F.when(col('DIFF') < -900000, None).otherwise(col('VALUE')))

Is it possible to add another condition in the when clause, something like:

df2 = df.withColumn("VALUE", F.when(col('DIFF') < -900000 | col('DIFF') > 900000, None).otherwise(col('VALUE')))

However, this throws an Method does not exist error.

Any ideas?

Thanks in advance.

JA_DATA
  • 23
  • 3

1 Answers1

2

Like so:

df2 = df.withColumn("VALUE", F.when((col('DIFF') < -900000 ) | (col('DIFF') > 900000), None).otherwise(col('VALUE')))
MGJ-123
  • 614
  • 4
  • 19