Pyspark 数据帧 LIKE 运算符 [英] Pyspark dataframe LIKE operator
本文介绍了Pyspark 数据帧 LIKE 运算符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Pyspark 中 LIKE 运算符的等价物是什么?例如我想做:
What is the equivalent in Pyspark for LIKE operator? For example I would like to do:
SELECT * FROM table WHERE column LIKE "*somestring*";
寻找像这样简单的东西(但这不起作用):
looking for something easy like this (but this is not working):
df.select('column').where(col('column').like("*s*")).show()
推荐答案
您可以使用 where
和 col
函数来做同样的事情.where
将用于根据条件过滤数据(这里是,如果列类似于 '%string%'
).col('col_name')
用于表示条件,like
是运算符:
You can use where
and col
functions to do the same. where
will be used for filtering of data based on a condition (here it is, if a column is like '%string%'
). The col('col_name')
is used to represent the condition and like
is the operator:
df.where(col('col1').like("%string%")).show()
这篇关于Pyspark 数据帧 LIKE 运算符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文