# cast

> For the complete documentation index, see [llms.txt](https://kotlin.github.io/dataframe/llms.txt).

Changes the type argument of the [DataFrame](dataframe.html) instance without changing its contents.

API reference: [cast](https://kotlin.github.io/dataframe/api-docs/core/org.jetbrains.kotlinx.dataframe.api/cast.html)

```KOTLIN
cast<T>(verify = false)
```

Related operations: [Adjust schema](adjustschema.html)

Parameters:

* `verify: Boolean = false` — when `true`, the function throws an exception if the [DataFrame](dataframe.html) instance doesn't match the given schema. Otherwise, it just changes the formal type without actual data checks.

Use this operation to change the formal type of a [DataFrame](dataframe.html) instance to match the expected schema and enable generated [extension properties](extensionpropertiesapi.html) for it.

```KOTLIN
@DataSchema
interface Person {
    val age: Int
    val name: String
}

df.cast<Person>()
```

To convert [DataFrame](dataframe.html) columns to match given schema, use [convertTo](convertto.html) operation.

Reusing implicitly generated schema

```KOTLIN
castTo<T>(df: DataFrame<T>)
```

In notebooks, dataframe types are implicitly generated.

![Implicitly generated schema](images/implicitlyGeneratedSchema.png)

This type can be referred to, but its name will change whenever you re-execute cells. Here's how you can do it in a more robust way:

```KOTLIN
val sample = DataFrame.readJson("sample.json")
```

```KOTLIN
for (file in files) {
    // df here is expected to have the same structure as sample
    val df = DataFrame.readJson(file).castTo(sample)
    val count = df.count { perf > 10.0 }
    println("$file: $count")
}
```

