Collection.cast#
- classmethod Collection.cast( ) Self[source]#
Initialize a collection by casting all members into their correct schemas.
This method calls
cast()on every member, thus, removing superfluous columns and casting to the correct dtypes for all input data frames.You should typically use
validate()orfilter()to obtain instances of the collection as this method does not guarantee that the returned collection upholds any invariants. Nonetheless, it may be useful to use in instances where it is known that the provided data adheres to the collection’s invariants.- Parameters:
data – The data for all members. The dictionary must contain exactly one entry per member with the name of the member as key.
- Returns:
The initialized collection.
- Raises:
ValueError – If an insufficient set of input data frames is provided i.e. if any required member of this collection is missing in the input.
Attention
For lazy frames, casting is not performed eagerly. This prevents collecting the lazy frames’ schemas but also means that a call to
polars.LazyFrame.collect()further down the line might fail because of the cast and/or missing columns.