Explorer.DataFrame mutation help

I have an Explorer.DataFrame, like so.

df = DataFrame.new(
  goal: Enum.to_list(60..1) |> Series.from_list()

df = DataFrame.put(df, :day_of_week, Explorer.Series.transform(Series.subtract(df["day"], 1), &get_day_of_week/1))

Simple enough. But now I need to create another column that relies on the others. Something like — if the day of week is 1, multiple the goal column value by 3, otherwise by 6.

I’m oversimplifying my use case, but it seems like when I need to do conditional logic with multiple columns, I can’t quite finesse the code.

Am I stuck with converting to a list, doing work, and then back to a series?

You could use Series.select to implement what you’re describing:

  Series.equal(df["day_of_week"], 1)
  Series.multiply(df["goal"], 3),
  Series.multiply(df["goal"], 6)

Thank you!