Adjust schema
The DataFrame interface has type argument T that doesn't affect the contents of DataFrame, but marks DataFrame with a type that represents the data schema that this DataFrame is supposed to have. This argument is used to generate extension properties for typed data access.
API reference: cast, convertTo
Another place where this argument has a special role is in interop with data classes:
List<T>->DataFrame<T>: toDataFrameDataFrame<T>->List<T>: toList
Actual data in DataFrame may diverge from compile-time schema marker T due to dynamic nature of data inside DataFrame. However, at some points of code you may know exactly what DataFrame schema is expected. To match your knowledge with expected real-time DataFrame contents you can use one of two functions:
cast— change type argument ofDataFrameto the expected schema without changing data inDataFrame.convertTo— convertDataFramecontents to match the expected schema.
Alternatively, use requireColumn to incrementally add type information to compile time schema.