Column.auto_cast
auto_castshrink_types
Group: Conversions
Aliases: auto_value_type
Documentation
Change the value type of the column to a more specific one, based on its contents.
Arguments
- shrink_types: If set- True, smaller types will be chosen if possible, according to the rules below. Defaults to- False.
Remarks
Auto Type Selection Rules
- If a Mixedcolumn can be assigned a single type, likeCharorInteger, that will be used.
- Text columns are not parsed. To do that, use the parsemethod.
- If a Floatcolumn contains only integers, it will be converted to an Integer column.
- If a Decimalcolumn contains only integers that could fit in a 64-bit integer storage, it will be converted to an Integer column.
- If shrink_typesisFalse(default), no other transformations are applied.
- However, if shrink_typesis set toTrue, then:- Integer columns will be assigned the smallest size that can fit all
values (down to 16-bit integers; converting to the Bytetype has to be done manually throughcast).
- If all elements in a text column have the same length, the type will become fixed length.
- Otherwise, if a text column is variable length, but all text elements are no longer than 255 characters, the column will get a max length of 255. Otherwise, the column size limit will stay unchanged.
 
- Integer columns will be assigned the smallest size that can fit all
values (down to 16-bit integers; converting to the