Skip to content
Snippets Groups Projects
Commit 028ad4bd authored by Reynold Xin's avatar Reynold Xin
Browse files

[SPARK-7509][SQL] DataFrame.drop in Python for dropping columns.

Author: Reynold Xin <rxin@databricks.com>

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

9d7d5ec [Reynold Xin] [SPARK-7509][SQL] DataFrame.drop in Python for dropping columns.
parent 4b5e1fe9
No related branches found
No related tags found
No related merge requests found
...@@ -1014,7 +1014,7 @@ class DataFrame(object): ...@@ -1014,7 +1014,7 @@ class DataFrame(object):
@ignore_unicode_prefix @ignore_unicode_prefix
def withColumnRenamed(self, existing, new): 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 existing: string, name of the existing column to rename.
:param col: string, new name of the column. :param col: string, new name of the column.
...@@ -1027,6 +1027,18 @@ class DataFrame(object): ...@@ -1027,6 +1027,18 @@ class DataFrame(object):
for c in self.columns] for c in self.columns]
return self.select(*cols) 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): def toPandas(self):
"""Returns the contents of this :class:`DataFrame` as Pandas ``pandas.DataFrame``. """Returns the contents of this :class:`DataFrame` as Pandas ``pandas.DataFrame``.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment