I have a very large complex ibis script with a portion calculating some columns. at the end, I need to ibis.to_sql(t) to get a sql statement for my python. So I can’t use pandas
lets say i have this table
import ibis from ibis import _ ibis.options.interactive = True t = ibis.memtable( { "fruit": ["apple", "apple", "banana", "orange"], "price": [0.5, 0.5, 0.25, 0.33], "order": [1, 2, 3, 4], } )
is there a way to output
┏━━━━━━━━┳━━━━━━━━━
┃ fruit ┃ price ┃ order ┃cumsum_price
┡━━━━━━━━╇━━━━━━━━━
│ string │ float64 │ int64 │ int64 │
├────────┼─────────━━━━━━
│ apple │ 0.50 │ 1 │ 0.50
│ apple │ 0.50 │ 2 │ 1.0
│ banana │ 0.25 │ 3 │ 1.25
│ orange │ 0.33 │ 4 │ 1.58
└────────┴─────────━━━━━━
I attempted something like this
t = t.mutate(cumsum_price = t['price']+t.cumsum_price.lag().over(order_by=[t.order])
Which does not work.
Again, i cannot use pandas, I need to use Ibis to output sql