Fix labels for mlr histogram --auto (#1089)

This commit is contained in:
John Kerl 2022-09-03 09:55:44 -04:00 committed by GitHub
parent 87faddd661
commit 4a53a6b278
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 40 additions and 2 deletions

View file

@ -367,11 +367,11 @@ func (tr *TransformerHistogram) emitAuto(
outrec.PutReference(
tr.outputPrefix+"bin_lo",
mlrval.FromFloat((lo+float64(i))/mul),
mlrval.FromFloat(lo+(float64(i)/mul)),
)
outrec.PutReference(
tr.outputPrefix+"bin_hi",
mlrval.FromFloat((lo+float64(i+1))/mul),
mlrval.FromFloat(lo+(float64(i+1)/mul)),
)
for _, valueFieldName := range tr.valueFieldNames {

View file

@ -0,0 +1 @@
mlr --icsv --opprint histogram --nbins 9 --auto -f x test/input/histo2.csv

View file

View file

@ -0,0 +1,10 @@
bin_lo bin_hi x_count
100.00000000 122.22222222 1
122.22222222 144.44444444 0
144.44444444 166.66666667 0
166.66666667 188.88888889 0
188.88888889 211.11111111 2
211.11111111 233.33333333 0
233.33333333 255.55555556 0
255.55555556 277.77777778 0
277.77777778 300.00000000 1

View file

@ -0,0 +1 @@
mlr --icsv --opprint histogram --nbins 9 --auto -f y test/input/histo2.csv

View file

View file

@ -0,0 +1,10 @@
bin_lo bin_hi y_count
20.00000000 26.66666667 1
26.66666667 33.33333333 0
33.33333333 40.00000000 0
40.00000000 46.66666667 2
46.66666667 53.33333333 0
53.33333333 60.00000000 0
60.00000000 66.66666667 0
66.66666667 73.33333333 0
73.33333333 80.00000000 1

View file

@ -0,0 +1 @@
mlr --icsv --opprint histogram --nbins 9 --auto -f x,y test/input/histo2.csv

View file

View file

@ -0,0 +1,10 @@
bin_lo bin_hi x_count y_count
20.00000000 51.11111111 0 3
51.11111111 82.22222222 0 1
82.22222222 113.33333333 1 0
113.33333333 144.44444444 0 0
144.44444444 175.55555556 0 0
175.55555556 206.66666667 2 0
206.66666667 237.77777778 0 0
237.77777778 268.88888889 0 0
268.88888889 300.00000000 1 0

5
test/input/histo2.csv Normal file
View file

@ -0,0 +1,5 @@
x,y
100,20
200,40
300,41
200,80
1 x y
2 100 20
3 200 40
4 300 41
5 200 80