explorer icon indicating copy to clipboard operation
explorer copied to clipboard

Allow operation between Series and LazySeries

Open nallwhy opened this issue 3 years ago • 4 comments

  • [ ] Series + LazySeries -> LazySeries
  • [x] LazySeries + Series -> LazySeries

The code below should work.

df = Explorer.DataFrame.new(%{a: [1, 2, 3]})

df
|> Explorer.DataFrame.mutate_with(&%{
  b: Explorer.Series.add(&1[:a], Explorer.Series.from_list([1, 2, 3])),
  c: Explorer.Series.add(Explorer.Series.from_list([1, 2, 3]), &1[:a])
})

Reference: https://github.com/pola-rs/polars/pull/4988

nallwhy avatar Oct 10 '22 13:10 nallwhy

Let me try to handle this issue

nallwhy avatar Oct 10 '22 13:10 nallwhy

Hmm.. maybe I misunderstood the reference PR.

For the arithmetic operations, polars do series + expr -> series. right?

I need to check series + expr -> expr, expr + series -> expr works in polars first.

nallwhy avatar Oct 10 '22 15:10 nallwhy

@nallwhy I think you need to transform the series to a literal value expression first. Maybe https://docs.rs/polars/latest/polars/series/struct.Series.html#method.lit does the trick, but I'm not sure.

philss avatar Oct 10 '22 16:10 philss

@philss Thanks! It works :)

nallwhy avatar Oct 10 '22 16:10 nallwhy