Pyspark alter column with substring

前端 未结 4 1884
耶瑟儿~
耶瑟儿~ 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:09

    if the goal is to remove '_' from the column names then I would use list comprehension instead:

    df.select(
        [ col(c).alias(c.replace('_', '') ) for c in df.columns ]
    )
    

提交回复
热议问题