本文簡要介紹
pyspark.sql.functions.substring_index
的用法。用法:
pyspark.sql.functions.substring_index(str, delim, count)
在計數出現分隔符 delim 之前從字符串 str 返回子字符串。如果 count 是正數,則返回最後定界符左邊的所有內容(從左邊開始計數)。如果 count 為負數,則返回最終分隔符右側的每個(從右側開始計數)。 substring_index 在搜索 delim 時執行區分大小寫的匹配。
1.5.0 版中的新函數。
例子:
>>> df = spark.createDataFrame([('a.b.c.d',)], ['s']) >>> df.select(substring_index(df.s, '.', 2).alias('s')).collect() [Row(s='a.b')] >>> df.select(substring_index(df.s, '.', -3).alias('s')).collect() [Row(s='b.c.d')]
相關用法
- Python pyspark substring用法及代碼示例
- Python pyspark session_window用法及代碼示例
- Python pyspark second用法及代碼示例
- Python pyspark slice用法及代碼示例
- Python pyspark size用法及代碼示例
- Python pyspark struct用法及代碼示例
- Python pyspark spark_partition_id用法及代碼示例
- Python pyspark split用法及代碼示例
- Python pyspark shiftleft用法及代碼示例
- Python pyspark schema_of_csv用法及代碼示例
- Python pyspark sequence用法及代碼示例
- Python pyspark sort_array用法及代碼示例
- Python pyspark sha1用法及代碼示例
- Python pyspark shiftright用法及代碼示例
- Python pyspark shiftrightunsigned用法及代碼示例
- Python pyspark sql用法及代碼示例
- Python pyspark sha2用法及代碼示例
- Python pyspark schema_of_json用法及代碼示例
- Python pyspark sentences用法及代碼示例
- Python pyspark soundex用法及代碼示例
- Python pyspark shuffle用法及代碼示例
- Python pyspark create_map用法及代碼示例
- Python pyspark date_add用法及代碼示例
- Python pyspark DataFrame.to_latex用法及代碼示例
- Python pyspark DataStreamReader.schema用法及代碼示例
注:本文由純淨天空篩選整理自spark.apache.org大神的英文原創作品 pyspark.sql.functions.substring_index。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。