tidypolars_extra.type_conversion¶
Functions¶
|
Convert column to string. Alias to as_logical (R naming). |
|
Convert to factor. Alias for as_factor |
|
Convert to string. Defaults to Utf8. |
|
Convert to factor (R naming), equlivalent to Enum or |
|
Convert to float. Defaults to Float64. |
|
Convert to integer. Defaults to Int64. |
|
Convert to a boolean (polars) or 'logical' (R naming) |
|
Convert column to string. Alias to as_character (R naming). |
|
General type conversion. |
Module Contents¶
- tidypolars_extra.type_conversion.as_boolean(x)[source]¶
Convert column to string. Alias to as_logical (R naming).
- tidypolars_extra.type_conversion.as_categorical(*args, **kwargs)[source]¶
Convert to factor. Alias for as_factor
- tidypolars_extra.type_conversion.as_character(x)[source]¶
Convert to string. Defaults to Utf8.
- Parameters:
x (Str) – Column to operate on
Examples
>>> df.mutate(string_x = tp.as_string('x')) # or equivalently >>> df.mutate(character_x = tp.as_character('x'))
- tidypolars_extra.type_conversion.as_factor(x, levels=None)[source]¶
Convert to factor (R naming), equlivalent to Enum or Categorical (polars), depending on whether ‘levels’ is provided.
- Parameters:
x (Str) – Column to operate on
levels (list of str) – Categories to use in the factor. The catogories will be ordered as they appear in the list. If None (default), it will create an unordered factor (polars Categorical).
Examples
>>> df.mutate(factor_x = tp.as_factor('x')) # or equivalently >>> df.mutate(categorical_x = tp.as_categorical('x'))
- tidypolars_extra.type_conversion.as_float(x)[source]¶
Convert to float. Defaults to Float64.
- Parameters:
x (Expr, Series) – Column to operate on
Examples
>>> df.mutate(float_x = tp.as_float(col('x')))
- tidypolars_extra.type_conversion.as_integer(x)[source]¶
Convert to integer. Defaults to Int64.
- Parameters:
x (Expr) – Column to operate on
Examples
>>> df.mutate(int_x = tp.as_integer(col('x')))
- tidypolars_extra.type_conversion.as_logical(x)[source]¶
Convert to a boolean (polars) or ‘logical’ (R naming)
- Parameters:
x (Str) – Column to operate on
Examples
>>> df.mutate(bool_x = tp.as_boolean(col('x'))) # or equivalently >>> df.mutate(logical_x = tp.as_logical(col('x')))