简体   繁体   English

Python - 使用 Pyspark 检查单个值是否在 with.isin() 列中是否正确?

[英]Python - is it correct to check if a single value is in a column with .isin() with Pyspark?

In PySpark when I want to check if one of the values is in a column I use .isin() :在 PySpark 中,当我想检查其中一个值是否在我使用的列中时.isin()

F.col('metric').isin({"Metric_value1, Metric_value2"})

Is it correct to perform the same check for a single value like below or there's a better way to do this?像下面这样对单个值执行相同的检查是否正确,或者有更好的方法来做到这一点?

F.col('metric').isin({"Metric_value1"})

In Pyspark, isin() is generally used to compare a column value against multiple values and return results if any of those values matches the column value.在 Pyspark 中,isin isin()通常用于将列值与多个值进行比较,如果其中任何一个值与列值匹配,则返回结果。

For a single value, you could directly use comparison operator like:对于单个值,您可以直接使用比较运算符,例如:

F.col('metric')=='Metric_value1'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM