Apache spark Spark\uuu getnewargs\uuuu错误。。。方法或([class java.lang.String])不存在

Apache spark Spark\uuu getnewargs\uuuu错误。。。方法或([class java.lang.String])不存在,apache-spark,pyspark,apache-spark-sql,Apache Spark,Pyspark,Apache Spark Sql,我试图根据列值是否位于另一列中向DataFrame添加列,如下所示: df = df.withColumn('new_column', when(df['color']=='blue' | df['color']=='green', 'A').otherwise('WD')) 运行代码后,我得到以下错误: Py4JError: An error occurred while calling o59.or. Trace: py4j.Py4JException: Method or([class

我试图根据列值是否位于另一列中向DataFrame添加列,如下所示:

df = df.withColumn('new_column', when(df['color']=='blue' | df['color']=='green', 'A').otherwise('WD'))
运行代码后,我得到以下错误:

Py4JError: An error occurred while calling o59.or. Trace:
py4j.Py4JException: Method or([class java.lang.String]) does not exist
    at py4j.reflection.ReflectionEngine.getMethod(ReflectionEngine.java:318)
    at py4j.reflection.ReflectionEngine.getMethod(ReflectionEngine.java:326)
    at py4j.Gateway.invoke(Gateway.java:274)
    at py4j.commands.AbstractCommand.invokeMethod(AbstractCommand.java:132)
    at py4j.commands.CallCommand.execute(CallCommand.java:79)
    at py4j.GatewayConnection.run(GatewayConnection.java:214)
    at java.lang.Thread.run(Thread.java:748)
我该如何克服这个问题?
我正在使用PySpark 2.3.0

当使用多个条件时,由于运算符的优先级,每个条件都需要分开

df=df.withColumn('new_column',when((df['color']=='blue')|(df['color']=='green'),'A').otherwise('WD'))