Pyspark中的以下语句引发了一个问题 .select ('Substr(trim(Name), -3))')
.select ('Substr(trim(Name), -3))')
.select ('Substr(trim(Name), -3))')
输入数据为 RAMS 123,预期输出为 123
pyspark中可用的substr()方法。
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|
+----------------------+