Pyspark中的以下语句引发了一个问题 .select('Substr(trim(Name),-3))')
.select ('Substr(trim(Name), -3))')
.select ('Substr(trim(Name), -3))')
输入数据为RAMS 123,预期输出为123
答案 0 :(得分:0)
substr()方法在pyspark中可用。
myDf = sqlContext.createDataFrame([('Alex',"30"),("Hitesh R","34"),("David B","35")],("Name","Age"))
myDf.show()
+--------+---+
| Name|Age|
+--------+---+
| Alex| 30|
|Hitesh R| 34|
| David B| 35|
+--------+---+
myDf.select(myDf['Name'].substr(-3,3)).show()
+----------------------+
|substring(Name, -3, 3)|
+----------------------+
| lex|
| h R|
| d B|
+----------------------+