scicloj / tablecloth

Dataset manipulation library built on the top of tech.ml.dataset
https://scicloj.github.io/tablecloth
MIT License
288 stars 23 forks source link

aggregate-columns might lose the order of columns #35

Closed daslu closed 3 years ago

daslu commented 3 years ago

Tested with scicloj/tablecloth {:mvn/version "5.05"}:


(-> (array-map
     :a [1 1]
     :b 2
     :c 3
     :d 4
     :e 5
     :f 6
     :g 7
     :h 8
     :i 9)
    tablecloth.api/dataset
    (tablecloth.api/aggregate-columns [:a :b :c :d :e :f :g :h :i]
                                      tech.v3.datatype.functional/sum))

_unnamed [1 9]:

|       :e |       :g |       :c |       :h |       :b |       :d |       :f |       :i |       :a |
|----------|----------|----------|----------|----------|----------|----------|----------|----------|
|     10.0 |     14.0 |      6.0 |     16.0 |      4.0 |      8.0 |     12.0 |     18.0 |      2.0 |
genmeblog commented 3 years ago

Probably there is a regular map along the path.

genmeblog commented 3 years ago

(deleted previous comment, which is probably not true in this case... - but may be in other cases)

genmeblog commented 3 years ago

Ok, got it working with array-map

(-> (array-map
     :a [1 1]
     :b 2
     :c 3
     :d 4
     :e 5
     :f 6
     :g 7
     :h 8
     :i 9)
    dataset
    (aggregate-columns [:a :b :c :d :e :f :g :h :i]
                       tech.v3.datatype.functional/sum))
;; => _unnamed [1 9]:
;;    |       :a |       :b |       :c |       :d |       :e |       :f |       :g |       :h |       :i |
;;    |----------|----------|----------|----------|----------|----------|----------|----------|----------|
;;    |      2.0 |      4.0 |      6.0 |      8.0 |     10.0 |     12.0 |     14.0 |     16.0 |     18.0 |

I wonder where we can find another place around this issue.

genmeblog commented 3 years ago

fixed in 5.11

daslu commented 3 years ago

Wonderful!