chevron_left
PySpark Column
check_circle
Mark as learned thumb_up
0
thumb_down
0
chat_bubble_outline
0
auto_stories new
settings
PySpark Column | contains method
Machine Learning
chevron_rightPySpark
chevron_rightDocumentation
chevron_rightPySpark Column
schedule Jul 1, 2022
Last updated local_offer PySpark
Tags tocTable of Contents
expand_more Check out the interactive map of data science
PySpark Column's contains(~)
method returns a Column
object of booleans where True
corresponds to column values that contain the specified substring.
Parameters
1. other
| string
or Column
A string or a Column
to perform the check.
Return Value
A Column
object of booleans.
Examples
Consider the following PySpark DataFrame:
+-----+---+| name|age|+-----+---+| Alex| 20|| Bob| 30||Cathy| 40|+-----+---+
Getting rows that contain a substring in PySpark DataFrame
To get rows that contain the substring "le"
:
Here, F.col("name").contains("le")
returns a Column
object holding booleans where True
corresponds to strings that contain the substring "le"
:
In our solution, we use the filter(~)
method to extract rows that correspond to True
.
Published by Isshin Inada
Edited by 0 others
Did you find this page useful?
thumb_up
thumb_down
Ask a question or leave a feedback...
Official PySpark Documentation
https://spark.apache.org/docs/latest/api/python/reference/api/pyspark.sql.Column.contains.html
thumb_up
0
thumb_down
0
chat_bubble_outline
0
settings
Enjoy our search
Hit / to insta-search docs and recipes!