When doing a / operator on two columns in tablecloth, I get an ArithmeticException due to "Non-terminating decimal expansion; no exact representable decimal result.". In plain clojuse you solve this with (with-precision .. ) however due to tech datatype operating on another thread simply doing (with-precision 5 (tc// does not work. Any idea?
Hi. It would be helpful to provide a reproducible example we could explore.
(-> (tablecloth.api/dataset {:A [(bigdec 10)]
:B [(bigdec 3)]})
(tablecloth.api// :C [:A :B])
)
Thanks. It is an intresting proposal to extend column arithmetic to bigdec. This actually relates to the undelying dtype-next library.
I'd recommend discussing it with the library authors at the # channel of the Clojurians Zulip chat.
For now, you can use tc/map-columns.
(with-precision
5
(-> (tablecloth.api/dataset {:A [(bigdec 10)]
:B [(bigdec 3)]})
(tablecloth.api/map-columns
:C
[:A :B]
/)))OK, thank you! In general do you recommend against using bigdec in tablecloth datasets? I use monetary values and for that usually bigdecimal is the standard practice
You can use any value inside datasets. I think it just means you will not be able to enjoy the performance benefits (memory and time) you would have with primitive numeric types.
I see, maybe I'll do a test and switch to double and see how precision degrades and speed/memory improves
thank you