Skip to content

Commit

Permalink
Merge pull request #180 from behrica/fix#40
Browse files Browse the repository at this point in the history
support "string" in src-column
  • Loading branch information
genmeblog authored Jan 13, 2025
2 parents f7c63a2 + 9082948 commit 5c4098a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/tablecloth/api/join_separate.clj
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,10 @@
"
([ds src-column opts]
(assert (not (grouped? ds)) "Not supported on grouped datasets")
(let [len-arrays (-> ds src-column first count)
(let [len-arrays (-> ds (get src-column) first count)
new-ds
(->
(dtt/concat-buffers (ds src-column))
(dtt/concat-buffers (get ds src-column))
(tens/reshape [(ds/row-count ds) len-arrays])
(tech.v3.dataset.tensor/tensor->dataset))

Expand Down
11 changes: 10 additions & 1 deletion test/tablecloth/api/join_separate_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,16 @@
:y [:a :b]})
(api/array-column->columns :x)
(api/rows :as-maps))
=> [{:y :a 0 1.0 1 2.0 2 3.0} {:y :b 0 4.0 1 5.0 2 6.0}])
=> [{:y :a 0 1.0 1 2.0 2 3.0} {:y :b 0 4.0 1 5.0 2 6.0}]

(-> {"a" [[4 4] [3 2] [2 0]]}
api/dataset
(api/array-column->columns "a" { :prefix "c"})
(api/rows :as-maps)

)
=> [{"c-0" 4, "c-1" 4} {"c-0" 3, "c-1" 2} {"c-0" 2, "c-1" 0}]
)

(fact "array-column->columns works can prefix columns with key-word"
(-> (api/dataset {:x [(double-array [1 2 3])
Expand Down

0 comments on commit 5c4098a

Please sign in to comment.