[SPARK-11279][PYSPARK] Add DataFrame#toDF in PySpark
Author: Jeff Zhang <zjffdu@apache.org> Closes #9248 from zjffdu/SPARK-11279.
This commit is contained in:
parent
07ced43424
commit
05c4bdb579
|
@ -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``.
|
||||
|
|
Loading…
Reference in a new issue