aboutsummaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorReynold Xin <rxin@databricks.com>2015-05-11 20:04:36 -0700
committerReynold Xin <rxin@databricks.com>2015-05-11 20:04:36 -0700
commit028ad4bd29106747089bb9a863e9a8dee738770e (patch)
tree57e4df2e4834ae2594f341c0ed46579be6079b79 /python
parent4b5e1fe94c65f0feb77d849e7defa42b6007628d (diff)
downloadspark-028ad4bd29106747089bb9a863e9a8dee738770e.tar.gz
spark-028ad4bd29106747089bb9a863e9a8dee738770e.tar.bz2
spark-028ad4bd29106747089bb9a863e9a8dee738770e.zip
[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.
Diffstat (limited to 'python')
-rw-r--r--python/pyspark/sql/dataframe.py14
1 files changed, 13 insertions, 1 deletions
diff --git a/python/pyspark/sql/dataframe.py b/python/pyspark/sql/dataframe.py
index 4eaa8d9c57..72180f6d05 100644
--- a/python/pyspark/sql/dataframe.py
+++ b/python/pyspark/sql/dataframe.py
@@ -1014,7 +1014,7 @@ class DataFrame(object):
@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.
@@ -1027,6 +1027,18 @@ class DataFrame(object):
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``.