remi 0.2.4 → 0.2.5
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
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a68e65a6146a37cea022e1f7cbf18574e16905f7
|
4
|
+
data.tar.gz: c944f32038d24deff54396591ca98a64b69ba296
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c016ce1f58bb37da6214c29263ddee66c3b46c9557539210be25517c2676ffc0abd6a3c3fb5b6406290a350c280a277bce0a4aedb14856266d423169f650eeaf
|
7
|
+
data.tar.gz: 4dc14a6c9653c12dea6ffaaef74ab7d1acc116308ec99e181d6756ae63db8d5a740f6c72e3d8b258f52fce160f8c3c2892405f96c82ce3985a3f11753db690d5
|
@@ -18,6 +18,6 @@ Feature: Tests the aggregate refinement to the Daru library
|
|
18
18
|
| a | 2017 | 4 |
|
19
19
|
And the following example record called 'expected result':
|
20
20
|
| Alpha | Year |
|
21
|
-
| a | 2016 |
|
22
|
-
| b | 2010 |
|
21
|
+
| a | Group a has a minimum value of 2016 |
|
22
|
+
| b | Group b has a minimum value of 2010 |
|
23
23
|
Then the target should match the example 'expected result'
|
@@ -9,9 +9,9 @@ class AggregateJob
|
|
9
9
|
|
10
10
|
define_transform :main, sources: :source_data, targets: :target_data do
|
11
11
|
|
12
|
-
mymin = lambda do |field, df, indicies|
|
12
|
+
mymin = lambda do |field, df, group_key, indicies|
|
13
13
|
values = indicies.map { |idx| df.row[idx][field] }
|
14
|
-
values.min
|
14
|
+
"Group #{group_key} has a minimum value of #{values.min}"
|
15
15
|
end
|
16
16
|
|
17
17
|
target_data.df = source_data.df.aggregate(by: :alpha, func: mymin.curry.(:year)).detach_index
|
@@ -21,16 +21,17 @@ module Remi
|
|
21
21
|
# Public: Allows the user to define an arbitrary aggregation function.
|
22
22
|
#
|
23
23
|
# by - The name of the DataFrame vector to use to group records.
|
24
|
-
# func - A lambda function that accepts
|
25
|
-
# is the DataFrame
|
26
|
-
# to
|
24
|
+
# func - A lambda function that accepts three arguments - the
|
25
|
+
# first argument is the DataFrame, the second is the
|
26
|
+
# key to the current group, and the third is the index
|
27
|
+
# of the elements belonging to a group.
|
27
28
|
#
|
28
29
|
# Example:
|
29
30
|
# df = Daru::DataFrame.new( { a: ['a','a','a','b','b'], year: ['2018','2015','2019', '2014', '2013'] })
|
30
31
|
#
|
31
|
-
# mymin = lambda do |field, df, indicies|
|
32
|
+
# mymin = lambda do |field, df, group_key, indicies|
|
32
33
|
# values = indicies.map { |idx| df.row[idx][field] }
|
33
|
-
# values.min
|
34
|
+
# "Group #{group_key} has a minimum value of #{values.min}"
|
34
35
|
# end
|
35
36
|
#
|
36
37
|
# df.aggregate(by: :a, func: mymin.curry.(:year))
|
@@ -41,7 +42,8 @@ module Remi
|
|
41
42
|
grouped = self.group_by(by)
|
42
43
|
::Daru::Vector.new(
|
43
44
|
grouped.groups.reduce({}) do |h, (key, indicies)|
|
44
|
-
|
45
|
+
group_key = key.size == 1 ? key.first : key
|
46
|
+
h[group_key] = func.(self, group_key, indicies)
|
45
47
|
h
|
46
48
|
end
|
47
49
|
)
|
data/lib/remi/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: remi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sterling Paramore
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-01-
|
11
|
+
date: 2016-01-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: daru
|