diff options
Diffstat (limited to 'python')
-rw-r--r-- | python/pyspark/sql/dataframe.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/python/pyspark/sql/dataframe.py b/python/pyspark/sql/dataframe.py index 36fc6e0611..3baff81477 100644 --- a/python/pyspark/sql/dataframe.py +++ b/python/pyspark/sql/dataframe.py @@ -1266,6 +1266,18 @@ class DataFrame(object): raise TypeError("col should be a string or a Column") return DataFrame(jdf, self.sql_ctx) + @ignore_unicode_prefix + def toDF(self, *cols): + """Returns a new class:`DataFrame` that with new specified column names + + :param cols: list of new column names (string) + + >>> df.toDF('f1', 'f2').collect() + [Row(f1=2, f2=u'Alice'), Row(f1=5, f2=u'Bob')] + """ + jdf = self._jdf.toDF(self._jseq(cols)) + return DataFrame(jdf, self.sql_ctx) + @since(1.3) def toPandas(self): """Returns the contents of this :class:`DataFrame` as Pandas ``pandas.DataFrame``. |