schema

Returns the runtime DataFrameSchema of the DataFrame this row is part of.

The result describes all columns of that DataFrame, not just the values of this one row, so every row of the same DataFrame gives the same schema. For a row taken out of a column group, it is the schema of that group.

A DataFrame has two schemas that do not have to agree: the runtime one, read from the columns it holds, and the compile-time one, read from the type argument T of DataFrame<T>. They differ when the type does not fit the columns, for example after a cast to a schema the data does not have; comparing them is how you notice.

Use print to write a schema out as a tree, and compare to relate two schemas to each other.

For more information: See schema on the documentation website.

Example

The examples below use the same DataFrame as the schema page on the documentation website: a name column group holding firstName and lastName, and the columns age, city, weight and isHappy.

// the columns of df, not the values of the single row
df.first().schema().columns.keys // [name, age, city, weight, isHappy]

Return

The DataFrameSchema of the DataFrame this row is part of.

See also


Returns the runtime DataFrameSchema of this DataFrame, read from the columns it holds.

Because it comes from the columns and not from the type argument of this DataFrame, it always fits the data. A column group contributes the schema of its nested columns; a frame column contributes only the columns that all of its non-empty dataframes have.

A DataFrame has two schemas that do not have to agree: the runtime one, read from the columns it holds, and the compile-time one, read from the type argument T of DataFrame<T>. They differ when the type does not fit the columns, for example after a cast to a schema the data does not have; comparing them is how you notice.

Use print to write a schema out as a tree, and compare to relate two schemas to each other.

For more information: See schema on the documentation website.

Example

The examples below use the same DataFrame as the schema page on the documentation website: a name column group holding firstName and lastName, and the columns age, city, weight and isHappy.

df.schema()

Written out, a column group is shown by indentation:

name:
firstName: String
lastName: String
age: Int
city: String?
weight: Int?
isHappy: Boolean

A frame column is shown by *, with the columns its dataframes share indented under it:

val nested = dataFrameOf("g")(
dataFrameOf("a", "b")(1, 2),
dataFrameOf("a", "b")(3, 4),
)
nested.schema()
g: *
a: Int
b: Int

Return

The DataFrameSchema of this DataFrame.

See also


Returns the runtime DataFrameSchema of this GroupBy seen as a DataFrame: the key columns, followed by a frame column holding the groups.

This is the schema of toDataFrame, so the group column carries its default name group here — unless a key column is already called group, in which case the groups get the next free name, group1.

A DataFrame has two schemas that do not have to agree: the runtime one, read from the columns it holds, and the compile-time one, read from the type argument T of DataFrame<T>. They differ when the type does not fit the columns, for example after a cast to a schema the data does not have; comparing them is how you notice.

Use print to write a schema out as a tree, and compare to relate two schemas to each other.

For more information: See schema on the documentation website.

Example

The examples below use the same DataFrame as the schema page on the documentation website: a name column group holding firstName and lastName, and the columns age, city, weight and isHappy.

df.groupBy { city }.schema()

The key column comes first, and the groups keep every column of df:

city: String?
group: *
name:
firstName: String
lastName: String
age: Int
city: String?
weight: Int?
isHappy: Boolean

Return

The DataFrameSchema of this GroupBy as a DataFrame.

See also