pyspark.sql.DataFrame.toDF

DataFrame.toDF(*cols)[source]

Returns a new DataFrame that with new specified column names

Parameters:
colsstr

new column names

Examples

>>> df.toDF('f1', 'f2').collect()
[Row(f1=2, f2='Alice'), Row(f1=5, f2='Bob')]