rover-df 1.0.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 +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +1 -1
- data/lib/rover/data_frame.rb +7 -7
- data/lib/rover/vector.rb +6 -6
- data/lib/rover/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: fc6b943b37b58eebf71e4a03cb289b2687fc0e0ae0975fddaede4c2ed1a6f33a
|
|
4
|
+
data.tar.gz: c430c0b73b54c17045fbd216b718c968f5b961c164617a89966253c249ad8935
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: fd49b878f232888a878700ec6a1eb0888c68318394bb3571d73019587fd4039fa15bc9eaef6a4b6f6a0d1184f5ef763648d17a28b9fdfb88fac917d973a5de45
|
|
7
|
+
data.tar.gz: a279d5b43ea48377a54b14e9dcded9a25d9912aeae1ac96bd517fdf42cff902f0f21f1db2ff933fff791f38c94b25d3bbb921d467cf45377fed52887e6b386de
|
data/CHANGELOG.md
CHANGED
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 [
|
|
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
|
|
data/lib/rover/data_frame.rb
CHANGED
|
@@ -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?
|
|
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?
|
|
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?
|
|
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
|
|
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].
|
|
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 :
|
|
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(
|
|
388
|
+
@vectors[k] = Vector.new(Array.new(size) + other[k].to_a)
|
|
389
389
|
end
|
|
390
390
|
self
|
|
391
391
|
end
|
data/lib/rover/vector.rb
CHANGED
|
@@ -305,12 +305,12 @@ module Rover
|
|
|
305
305
|
@data.cast_to(Numo::DFloat).var
|
|
306
306
|
end
|
|
307
307
|
|
|
308
|
-
def all?(
|
|
309
|
-
to_a.all?(
|
|
308
|
+
def all?(...)
|
|
309
|
+
to_a.all?(...)
|
|
310
310
|
end
|
|
311
311
|
|
|
312
|
-
def any?(
|
|
313
|
-
to_a.any?(
|
|
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?
|
|
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?
|
|
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