From 551fecd10daa4a3b9650f73ab3f3b07fa9941604 Mon Sep 17 00:00:00 2001 From: Matthias Meschede Date: Wed, 5 Mar 2025 17:21:20 +0100 Subject: [PATCH] adds And and Or operators to polars plugin nu_expressions (#15248) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit solution for #15242 adds "And" ``` ~/Projects/nushell> [[a, b]; [1., 2.], [3.,3.], [4., 6.]] | polars into-df | polars filter (((polars col a) > 2) and ((polars col b) < 5)) ╭───┬──────┬──────╮ │ # │ a │ b │ ├───┼──────┼──────┤ │ 0 │ 3.00 │ 3.00 │ ╰───┴──────┴──────╯ ``` adds "Or" ``` ~/Projects/nushell> [[a, b]; [1., 2.], [3.,3.], [4., 6.]] | polars into-df | polars filter (((polars col a) > 7) or ((polars col b) > 5)) ╭───┬──────┬──────╮ │ # │ a │ b │ ├───┼──────┼──────┤ │ 0 │ 4.00 │ 6.00 │ ╰───┴──────┴──────╯ ``` but not (yet) xor because polars doesn't have a direct expression for logical_xor ``` ~/Projects/nushell> [[a, b]; [1., 2.], [3.,3.], [4., 6.]] | polars into-df | polars filter (((polars col a) > 7) xor ((polars col b) > 5)) Error: nu::shell::operator_unsupported_type × The 'xor' operator does not work on values of type 'NuExpression'. ╭─[entry #5:1:94] 1 │ [[a, b]; [1., 2.], [3.,3.], [4., 6.]] | polars into-df | polars filter (((polars col a) > 7) xor ((polars col b) > 5)) · ─┬─┬ · │ ╰── NuExpression · ╰── does not support 'NuExpression' ╰──── ``` Co-authored-by: Jack Wright <56345+ayax79@users.noreply.github.com>