Pyspark alter column with substring

前端 未结 4 1919
耶瑟儿~
耶瑟儿~ 2021-01-04 08:20

Pyspark n00b... How do I replace a column with a substring of itself? I\'m trying to remove a select number of characters from the start and end of string.

f         


        
4条回答
  •  南笙
    南笙 (楼主)
    2021-01-04 09:01

    try:

    df.withColumn('COLUMN_NAME_fix', df['COLUMN_NAME'].substr(1, 10)).show()
    

    where 1 = start position in the string and 10 = number of characters to include from start position (inclusive)

提交回复
热议问题