Method: Polars::Expr#replace_strict
- Defined in:
- lib/polars/expr.rb
#replace_strict(old, new = NO_DEFAULT, default: NO_DEFAULT, return_dtype: nil) ⇒ Expr
Note:
The global string cache must be enabled when replacing categorical values.
Replace all values by different values.
8106 8107 8108 8109 8110 8111 8112 8113 8114 8115 8116 8117 8118 8119 8120 8121 8122 8123 8124 8125 |
# File 'lib/polars/expr.rb', line 8106 def replace_strict( old, new = NO_DEFAULT, default: NO_DEFAULT, return_dtype: nil ) if new.eql?(NO_DEFAULT) && old.is_a?(Hash) new = Series.new(old.values) old = Series.new(old.keys) end old = Utils.parse_into_expression(old, str_as_lit: true, list_as_series: true) new = Utils.parse_into_expression(new, str_as_lit: true, list_as_series: true) default = default.eql?(NO_DEFAULT) ? nil : Utils.parse_into_expression(default, str_as_lit: true) wrap_expr( _rbexpr.replace_strict(old, new, default, return_dtype) ) end |