How to exclude multiple columns in Spark dataframe in Python

后端 未结 3 1436
一整个雨季
一整个雨季 2020-12-03 00:46

I found PySpark has a method called drop but it seems it can only drop one column at a time. Any ideas about how to drop multiple columns at the same time?

3条回答
  •  难免孤独
    2020-12-03 01:44

    In PySpark 2.1.0 method drop supports multiple columns:

    PySpark 2.0.2:

    DataFrame.drop(col)
    

    PySpark 2.1.0:

    DataFrame.drop(*cols)
    

    Example:

    df.drop('col1', 'col2')
    

提交回复
热议问题