How to delete columns in pyspark dataframe

前端 未结 8 1551
滥情空心
滥情空心 2021-01-30 01:55
>>> a
DataFrame[id: bigint, julian_date: string, user_id: bigint]
>>> b
DataFrame[id: bigint, quan_created_money: decimal(10,0), quan_created_cnt: bigi         


        
8条回答
  •  广开言路
    2021-01-30 02:27

    Reading the Spark documentation I found an easier solution.

    Since version 1.4 of spark there is a function drop(col) which can be used in pyspark on a dataframe.

    You can use it in two ways

    1. df.drop('age').collect()
    2. df.drop(df.age).collect()

    Pyspark Documentation - Drop

提交回复
热议问题