How to delete columns in pyspark dataframe

前端 未结 8 1542
滥情空心
滥情空心 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:53

    Adding to @Patrick's answer, you can use the following to drop multiple columns

    columns_to_drop = ['id', 'id_copy']
    df = df.drop(*columns_to_drop)
    
    0 讨论(0)
  • 2021-01-30 02:54

    An easy way to do this is to user "select" and realize you can get a list of all columns for the dataframe, df, with df.columns

    drop_list = ['a column', 'another column', ...]
    
    df.select([column for column in df.columns if column not in drop_list])
    
    0 讨论(0)
提交回复
热议问题