Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion python/pyspark/sql/dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -986,7 +986,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 @@ -999,6 +999,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