---
title: toDF
description: "DataFrame.toDF method in PySpark: Returns a new DataFrame with new specified column names."
canonical_url: https://docs.databricks.com/gcp/en/pyspark/reference/classes/dataframe/toDF
---

# toDF

Returns a new DataFrame with new specified column names.

## Syntax

```
toDF(*cols: str)
```

## Parameters

| Parameter | Type  | Description                                                                                                                       |
| --------- | ----- | --------------------------------------------------------------------------------------------------------------------------------- |
| `*cols`   | tuple | a tuple of string new column name. The length of the list needs to be the same as the number of columns in the initial DataFrame. |

## Returns

`DataFrame`: DataFrame with new column names.

## Examples

```python
df = spark.createDataFrame([(14, "Tom"), (23, "Alice"),
    (16, "Bob")], ["age", "name"])
df.toDF('f1', 'f2').show()
# +---+-----+
# | f1|   f2|
# +---+-----+
# | 14|  Tom|
# | 23|Alice|
# | 16|  Bob|
# +---+-----+
```
