Pyspark n00b ...我如何用自己的子字符串替换列?我试图从字符串的开头和结尾删除选定数量的字符。Pyspark alter column with substring
from pyspark.sql.functions import substring
import pandas as pd
pdf = pd.DataFrame({'COLUMN_NAME':['_string_','_another string_']})
# this is what i'm looking for...
pdf['COLUMN_NAME_fix']=pdf['COLUMN_NAME'].str[1:-1]
df = sqlContext.createDataFrame(pdf)
# following not working... COLUMN_NAME_fix is blank
df.withColumn('COLUMN_NAME_fix', substring('COLUMN_NAME', 1, -1)).show()
这是非常接近,但略有不同Spark Dataframe column with last character of other column。再有就是这个 LEFT and RIGHT function in PySpark SQL
伟大的作品谢谢! – citynorman