Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
是否有一个内置函数可以添加一个新列,它是原始列的否定?
Spark SQL 有这个功能negative()。Pyspark 似乎没有继承这个功能。
negative()
df_new = df.withColumn(negative("orginal"))
假设您的列original是 boolean :
original
df_new = df.withColumn(~df["original"]) # Equivalent to "not original"