Skip to content

Commit

Permalink
[SPARK-7509][SQL] DataFrame.drop in Python for dropping columns.
Browse files Browse the repository at this point in the history
Author: Reynold Xin <rxin@databricks.com>

Closes apache#6068 from rxin/drop-column and squashes the following commits:

9d7d5ec [Reynold Xin] [SPARK-7509][SQL] DataFrame.drop in Python for dropping columns.
  • Loading branch information
rxin authored and jeanlyn committed Jun 12, 2015
1 parent e0f194b commit 5c5a36c
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion python/pyspark/sql/dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -1014,7 +1014,7 @@ def withColumn(self, colName, col):

@ignore_unicode_prefix
def withColumnRenamed(self, existing, new):
"""REturns a new :class:`DataFrame` by renaming an existing column.
"""Returns a new :class:`DataFrame` by renaming an existing column.
:param existing: string, name of the existing column to rename.
:param col: string, new name of the column.
Expand All @@ -1027,6 +1027,18 @@ def withColumnRenamed(self, existing, new):
for c in self.columns]
return self.select(*cols)

@ignore_unicode_prefix
def drop(self, colName):
"""Returns a new :class:`DataFrame` that drops the specified column.
:param colName: string, name of the column to drop.
>>> df.drop('age').collect()
[Row(name=u'Alice'), Row(name=u'Bob')]
"""
jdf = self._jdf.drop(colName)
return DataFrame(jdf, self.sql_ctx)

def toPandas(self):
"""Returns the contents of this :class:`DataFrame` as Pandas ``pandas.DataFrame``.
Expand Down

0 comments on commit 5c5a36c

Please sign in to comment.