Select columns in Pyspark Dataframe

前端 未结 6 1639
小鲜肉
小鲜肉 2021-02-03 21:45

I am looking for a way to select columns of my dataframe in pyspark. For the first row, I know I can use df.first() but not sure about columns given that they do

6条回答
  •  长情又很酷
    2021-02-03 22:30

    You can use an array and unpack it inside the select:

    cols = ['_2','_4','_5']
    df.select(*cols).show()
    

提交回复
热议问题