polars-df 0.18.0-x86_64-darwin → 0.19.0-x86_64-darwin

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Binary file
Binary file
Binary file
@@ -481,6 +481,8 @@ module Polars
481
481
  #
482
482
  # @param item [Object]
483
483
  # Item that will be checked for membership
484
+ # @param nulls_equal [Boolean]
485
+ # If true, treat null as a distinct value. Null values will not propagate.
484
486
  #
485
487
  # @return [Expr]
486
488
  #
@@ -501,9 +503,9 @@ module Polars
501
503
  # # │ ["x", "y"] ┆ false │
502
504
  # # │ ["a", "c"] ┆ true │
503
505
  # # └───────────────┴──────────┘
504
- def contains(item)
506
+ def contains(item, nulls_equal: true)
505
507
  item = Utils.parse_into_expression(item, str_as_lit: true)
506
- Utils.wrap_expr(_rbexpr.arr_contains(item))
508
+ Utils.wrap_expr(_rbexpr.arr_contains(item, nulls_equal))
507
509
  end
508
510
 
509
511
  # Count how often the value produced by `element` occurs.
data/lib/polars/expr.rb CHANGED
@@ -3734,15 +3734,7 @@ module Polars
3734
3734
  # # │ [9, 10] ┆ 3 ┆ false │
3735
3735
  # # └───────────┴──────────────────┴──────────┘
3736
3736
  def is_in(other, nulls_equal: false)
3737
- if other.is_a?(::Array)
3738
- if other.length == 0
3739
- other = Polars.lit(nil)._rbexpr
3740
- else
3741
- other = Polars.lit(Series.new(other))._rbexpr
3742
- end
3743
- else
3744
- other = Utils.parse_into_expression(other, str_as_lit: false)
3745
- end
3737
+ other = Utils.parse_into_expression(other)
3746
3738
  _from_rbexpr(_rbexpr.is_in(other, nulls_equal))
3747
3739
  end
3748
3740
  alias_method :in?, :is_in
@@ -16,20 +16,15 @@ module Polars
16
16
  elsif value.is_a?(::Date)
17
17
  return lit(::Time.utc(value.year, value.month, value.day)).cast(Date)
18
18
  elsif value.is_a?(Polars::Series)
19
- name = value.name
20
19
  value = value._s
21
- e = Utils.wrap_expr(Plr.lit(value, allow_object))
22
- if name == ""
23
- return e
24
- end
25
- return e.alias(name)
20
+ return Utils.wrap_expr(Plr.lit(value, allow_object, false))
26
21
  elsif (defined?(Numo::NArray) && value.is_a?(Numo::NArray)) || value.is_a?(::Array)
27
- return lit(Series.new("", value))
22
+ return Utils.wrap_expr(Plr.lit(Series.new("literal", [value.to_a], dtype: dtype)._s, allow_object, true))
28
23
  elsif dtype
29
- return Utils.wrap_expr(Plr.lit(value, allow_object)).cast(dtype)
24
+ return Utils.wrap_expr(Plr.lit(value, allow_object, true)).cast(dtype)
30
25
  end
31
26
 
32
- Utils.wrap_expr(Plr.lit(value, allow_object))
27
+ Utils.wrap_expr(Plr.lit(value, allow_object, true))
33
28
  end
34
29
  end
35
30
  end
@@ -481,6 +481,8 @@ module Polars
481
481
  #
482
482
  # @param item [Object]
483
483
  # Item that will be checked for membership
484
+ # @param nulls_equal [Boolean]
485
+ # If true, treat null as a distinct value. Null values will not propagate.
484
486
  #
485
487
  # @return [Expr]
486
488
  #
@@ -498,8 +500,8 @@ module Polars
498
500
  # # │ false │
499
501
  # # │ true │
500
502
  # # └───────┘
501
- def contains(item)
502
- Utils.wrap_expr(_rbexpr.list_contains(Utils.parse_into_expression(item)))
503
+ def contains(item, nulls_equal: true)
504
+ Utils.wrap_expr(_rbexpr.list_contains(Utils.parse_into_expression(item), nulls_equal))
503
505
  end
504
506
 
505
507
  # Join all string items in a sublist and place a separator between them.
@@ -746,9 +748,9 @@ module Polars
746
748
  # # │ {1,2,3} │
747
749
  # # │ {1,2,null} │
748
750
  # # └────────────┘
749
- def to_struct(n_field_strategy: "first_non_null", name_generator: nil)
751
+ def to_struct(n_field_strategy: "first_non_null", name_generator: nil, upper_bound: nil)
750
752
  raise Todo if name_generator
751
- Utils.wrap_expr(_rbexpr.list_to_struct(n_field_strategy, name_generator, 0))
753
+ Utils.wrap_expr(_rbexpr.list_to_struct(n_field_strategy, name_generator, nil))
752
754
  end
753
755
 
754
756
  # Run any polars expression against the lists' elements.
data/lib/polars/series.rb CHANGED
@@ -2144,18 +2144,33 @@ module Polars
2144
2144
 
2145
2145
  # Check if elements of this Series are in the other Series.
2146
2146
  #
2147
+ # @param nulls_equal [Boolean]
2148
+ # If true, treat null as a distinct value. Null values will not propagate.
2149
+ #
2147
2150
  # @return [Series]
2148
2151
  #
2149
2152
  # @example
2150
2153
  # s = Polars::Series.new("a", [1, 2, 3])
2151
- # s2 = Polars::Series.new("b", [2, 4])
2154
+ # s2 = Polars::Series.new("b", [2, 4, nil])
2152
2155
  # s2.is_in(s)
2153
2156
  # # =>
2154
- # # shape: (2,)
2157
+ # # shape: (3,)
2158
+ # # Series: 'b' [bool]
2159
+ # # [
2160
+ # # true
2161
+ # # false
2162
+ # # null
2163
+ # # ]
2164
+ #
2165
+ # @example
2166
+ # s2.is_in(s, nulls_equal: true)
2167
+ # # =>
2168
+ # # shape: (3,)
2155
2169
  # # Series: 'b' [bool]
2156
2170
  # # [
2157
2171
  # # true
2158
2172
  # # false
2173
+ # # false
2159
2174
  # # ]
2160
2175
  #
2161
2176
  # @example
@@ -2190,7 +2205,7 @@ module Polars
2190
2205
  # # true
2191
2206
  # # false
2192
2207
  # # ]
2193
- def is_in(other)
2208
+ def is_in(other, nulls_equal: false)
2194
2209
  super
2195
2210
  end
2196
2211
  alias_method :in?, :is_in
@@ -1403,7 +1403,7 @@ module Polars
1403
1403
  # # │ Can you feel the love tonight ┆ true │
1404
1404
  # # └─────────────────────────────────┴──────────────┘
1405
1405
  def contains_any(patterns, ascii_case_insensitive: false)
1406
- patterns = Utils.parse_into_expression(patterns, str_as_lit: false, list_as_series: true)
1406
+ patterns = Utils.parse_into_expression(patterns, str_as_lit: false)
1407
1407
  Utils.wrap_expr(
1408
1408
  _rbexpr.str_contains_any(patterns, ascii_case_insensitive)
1409
1409
  )
@@ -1474,9 +1474,9 @@ module Polars
1474
1474
  # # │ Can you feel the love tonight ┆ Can me feel the love tonight │
1475
1475
  # # └─────────────────────────────────┴─────────────────────────────────┘
1476
1476
  def replace_many(patterns, replace_with, ascii_case_insensitive: false)
1477
- patterns = Utils.parse_into_expression(patterns, str_as_lit: false, list_as_series: true)
1477
+ patterns = Utils.parse_into_expression(patterns, str_as_lit: false)
1478
1478
  replace_with = Utils.parse_into_expression(
1479
- replace_with, str_as_lit: true, list_as_series: true
1479
+ replace_with, str_as_lit: true
1480
1480
  )
1481
1481
  Utils.wrap_expr(
1482
1482
  _rbexpr.str_replace_many(
@@ -1,4 +1,4 @@
1
1
  module Polars
2
2
  # @private
3
- VERSION = "0.18.0"
3
+ VERSION = "0.19.0"
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: polars-df
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.18.0
4
+ version: 0.19.0
5
5
  platform: x86_64-darwin
6
6
  authors:
7
7
  - Andrew Kane
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-05-06 00:00:00.000000000 Z
11
+ date: 2025-05-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bigdecimal