rover-df 0.5.0 → 1.0.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1073cc7597ae35e09e20efb34bc8f22026fb597783a2746a69dbc46b6f6ce0cb
4
- data.tar.gz: c22191045efeb2892ffc0393ca37e19b700dcaf05ee1761840875e4c4eda8087
3
+ metadata.gz: fc6b943b37b58eebf71e4a03cb289b2687fc0e0ae0975fddaede4c2ed1a6f33a
4
+ data.tar.gz: c430c0b73b54c17045fbd216b718c968f5b961c164617a89966253c249ad8935
5
5
  SHA512:
6
- metadata.gz: 23c85ed31b9c2f481860d1304fb229094afbe66eef81075e0caa46d8e42c4052081b14cef1120614b04e2a45999a790dc73682b6aa60bf525ac9dda0b2d897ea
7
- data.tar.gz: 62ee77f8a3344751828711f0d0e73c3f2ae2ac9525d56c7bfbce114a715d0b1bf2f4e75ee475850e3dab6d606078606e19dfed3627bdb4b6a877928795c82d85
6
+ metadata.gz: fd49b878f232888a878700ec6a1eb0888c68318394bb3571d73019587fd4039fa15bc9eaef6a4b6f6a0d1184f5ef763648d17a28b9fdfb88fac917d973a5de45
7
+ data.tar.gz: a279d5b43ea48377a54b14e9dcded9a25d9912aeae1ac96bd517fdf42cff902f0f21f1db2ff933fff791f38c94b25d3bbb921d467cf45377fed52887e6b386de
data/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
1
+ ## 1.0.1 (2026-04-15)
2
+
3
+ - Added support for positional argument to `any?` and `all?` methods
4
+
5
+ ## 1.0.0 (2026-04-04)
6
+
7
+ - Switched to `numo-narray-alt`
8
+ - Dropped support for Ruby < 3.3
9
+
1
10
  ## 0.5.0 (2025-06-07)
2
11
 
3
12
  - Strings and symbols are no longer treated as different keys
data/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2020-2025 Andrew Kane
1
+ Copyright (c) 2020-2026 Andrew Kane
2
2
 
3
3
  MIT License
4
4
 
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Simple, powerful data frames for Ruby
4
4
 
5
- :mountain: Designed for data exploration and machine learning, and powered by [Numo](https://github.com/ruby-numo/numo-narray)
5
+ :mountain: Designed for data exploration and machine learning, and powered by [numo-narray-alt](https://github.com/yoshoku/numo-narray-alt)
6
6
 
7
7
  :evergreen_tree: Uses [Vega](https://github.com/ankane/vega) for visualization
8
8
 
@@ -20,12 +20,6 @@ gem "rover-df"
20
20
 
21
21
  A data frame is an in-memory table. It’s a useful data structure for data analysis and machine learning. It uses columnar storage for fast operations on columns.
22
22
 
23
- Try it out for forecasting by clicking the button below (it can take a few minutes to start):
24
-
25
- [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/ankane/ml-stack/master?filepath=Forecasting.ipynb)
26
-
27
- Use the `Run` button (or `SHIFT` + `ENTER`) to run each line.
28
-
29
23
  ## Creating Data Frames
30
24
 
31
25
  From an array
@@ -27,7 +27,7 @@ module Rover
27
27
  end
28
28
  elsif data.is_a?(Array)
29
29
  vectors = {}
30
- raise ArgumentError, "Array elements must be hashes" unless data.all? { |d| d.is_a?(Hash) }
30
+ raise ArgumentError, "Array elements must be hashes" unless data.all?(Hash)
31
31
  keys = data.flat_map(&:keys).uniq
32
32
  keys.each do |k|
33
33
  vectors[k] = []
@@ -65,7 +65,7 @@ module Rover
65
65
  end
66
66
 
67
67
  def [](where)
68
- if (where.is_a?(Vector) && where.to_numo.is_a?(Numo::Bit)) || where.is_a?(Numeric) || where.is_a?(Range) || (where.is_a?(Array) && where.all? { |v| v.is_a?(Integer) })
68
+ if (where.is_a?(Vector) && where.to_numo.is_a?(Numo::Bit)) || where.is_a?(Numeric) || where.is_a?(Range) || (where.is_a?(Array) && where.all?(Integer))
69
69
  new_vectors = {}
70
70
  @vectors.each do |k, v|
71
71
  new_vectors[k] = v[where]
@@ -269,7 +269,7 @@ module Rover
269
269
  when :bool
270
270
  :boolean
271
271
  when :object
272
- if @vectors[name].all? { |v| v.is_a?(String) }
272
+ if @vectors[name].all?(String)
273
273
  :string
274
274
  else
275
275
  raise "Unknown type"
@@ -313,10 +313,10 @@ module Rover
313
313
 
314
314
  @vectors.each do |k, v|
315
315
  v = summarize ? v.first(5).to_a + ["..."] + v.last(5).to_a : v.to_a
316
- width = ([k] + v).map(&:to_s).map(&:size).max
316
+ width = ([k] + v).map { |v2| v2.to_s.size }.max
317
317
  width = 3 if width < 3
318
318
 
319
- if lines.empty? || lines[-2].map { |l| l.size + spaces }.sum + width > 120
319
+ if lines.empty? || lines[-2].sum { |l| l.size + spaces } + width > 120
320
320
  line_start = lines.size
321
321
  lines << []
322
322
  v.size.times do |i|
@@ -382,10 +382,10 @@ module Rover
382
382
 
383
383
  size = self.size
384
384
  vectors.each do |k, v|
385
- @vectors[k] = Vector.new(v.to_a + (other[k] ? other[k].to_a : [nil] * other.size))
385
+ @vectors[k] = Vector.new(v.to_a + (other[k] ? other[k].to_a : Array.new(other.size)))
386
386
  end
387
387
  (other.vector_names - vector_names).each do |k|
388
- @vectors[k] = Vector.new([nil] * size + other[k].to_a)
388
+ @vectors[k] = Vector.new(Array.new(size) + other[k].to_a)
389
389
  end
390
390
  self
391
391
  end
data/lib/rover/group.rb CHANGED
@@ -35,7 +35,7 @@ module Rover
35
35
 
36
36
  # TODO make more efficient
37
37
  def grouped_dfs
38
- # cache here so we can reuse for multiple calcuations if needed
38
+ # cache here so we can reuse for multiple calculations if needed
39
39
  @grouped_dfs ||= begin
40
40
  groups = Hash.new { |hash, key| hash[key] = [] }
41
41
  i = 0
data/lib/rover/vector.rb CHANGED
@@ -172,6 +172,7 @@ module Rover
172
172
  def map(&block)
173
173
  # convert to Ruby first to cast properly
174
174
  # https://github.com/ruby-numo/numo-narray/issues/181
175
+ # numo-narray-alt has same behavior
175
176
  Vector.new(@data.to_a.map(&block))
176
177
  end
177
178
 
@@ -276,14 +277,13 @@ module Rover
276
277
  end
277
278
 
278
279
  def mean
279
- # currently only floats have mean in Numo
280
- # https://github.com/ruby-numo/numo-narray/issues/79
281
- @data.cast_to(Numo::DFloat).mean
280
+ @data.mean
282
281
  end
283
282
 
284
283
  def median
285
284
  # need to cast to get correct result
286
285
  # https://github.com/ruby-numo/numo-narray/issues/165
286
+ # numo-narray-alt has same behavior
287
287
  @data.cast_to(Numo::DFloat).median
288
288
  end
289
289
 
@@ -305,12 +305,12 @@ module Rover
305
305
  @data.cast_to(Numo::DFloat).var
306
306
  end
307
307
 
308
- def all?(&block)
309
- to_a.all?(&block)
308
+ def all?(...)
309
+ to_a.all?(...)
310
310
  end
311
311
 
312
- def any?(&block)
313
- to_a.any?(&block)
312
+ def any?(...)
313
+ to_a.any?(...)
314
314
  end
315
315
 
316
316
  def empty?
@@ -374,7 +374,7 @@ module Rover
374
374
  end
375
375
 
376
376
  def one_hot(drop: false, prefix: nil)
377
- raise ArgumentError, "All elements must be strings" unless all? { |vi| vi.is_a?(String) }
377
+ raise ArgumentError, "All elements must be strings" unless all?(String)
378
378
 
379
379
  new_vectors = {}
380
380
  # maybe sort values first
@@ -459,7 +459,7 @@ module Rover
459
459
  data = numo_type.cast(data)
460
460
  else
461
461
  data =
462
- if data.all? { |v| v.is_a?(Integer) }
462
+ if data.all?(Integer)
463
463
  Numo::Int64.cast(data)
464
464
  elsif data.all? { |v| v.is_a?(Numeric) || v.nil? }
465
465
  Numo::DFloat.cast(data.map { |v| v || Float::NAN })
data/lib/rover/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Rover
2
- VERSION = "0.5.0"
2
+ VERSION = "1.0.1"
3
3
  end
data/lib/rover.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # dependencies
2
- require "numo/narray"
2
+ require "numo/narray/alt"
3
3
 
4
4
  # modules
5
5
  require_relative "rover/data_frame"
@@ -40,7 +40,7 @@ module Rover
40
40
 
41
41
  raise ArgumentError, "Must specify headers" if headers == false
42
42
 
43
- # TODO use date converter in 0.5.0 - need to test performance
43
+ # TODO use date converter? need to test performance
44
44
  table = yield({converters: :numeric}.merge(csv_options))
45
45
 
46
46
  headers = nil if headers == true
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rover-df
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kane
@@ -10,19 +10,19 @@ cert_chain: []
10
10
  date: 1980-01-02 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
- name: numo-narray
13
+ name: numo-narray-alt
14
14
  requirement: !ruby/object:Gem::Requirement
15
15
  requirements:
16
16
  - - ">="
17
17
  - !ruby/object:Gem::Version
18
- version: 0.9.1.9
18
+ version: '0.10'
19
19
  type: :runtime
20
20
  prerelease: false
21
21
  version_requirements: !ruby/object:Gem::Requirement
22
22
  requirements:
23
23
  - - ">="
24
24
  - !ruby/object:Gem::Version
25
- version: 0.9.1.9
25
+ version: '0.10'
26
26
  email: andrew@ankane.org
27
27
  executables: []
28
28
  extensions: []
@@ -48,14 +48,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
48
48
  requirements:
49
49
  - - ">="
50
50
  - !ruby/object:Gem::Version
51
- version: '3.2'
51
+ version: '3.3'
52
52
  required_rubygems_version: !ruby/object:Gem::Requirement
53
53
  requirements:
54
54
  - - ">="
55
55
  - !ruby/object:Gem::Version
56
56
  version: '0'
57
57
  requirements: []
58
- rubygems_version: 3.6.7
58
+ rubygems_version: 4.0.6
59
59
  specification_version: 4
60
60
  summary: Simple, powerful data frames for Ruby
61
61
  test_files: []