Skip to content

Examples of Applying a Function in Python that takes in multiple inputs and using it to create a new column within an Ibis Dataframe? #8136

Answered by gforsyth
YCat33 asked this question in Q&A
Discussion options

You must be logged in to vote

This is using the Trino backend:

[ins] In [13]: t
Out[13]: 
┏━━━━━━━━━━━━━━┳━━━━━━━━━━━━┓
┃ cc_open_datedate_reg   ┃
┡━━━━━━━━━━━━━━╇━━━━━━━━━━━━┩
│ stringdate       │
├──────────────┼────────────┤
│ 2012-09-122013-09-13 │
│ 2003-08-312005-12-31 │
└──────────────┴────────────┘

[ins] In [14]: t.mutate(date_diff=_.date_reg.cast("date").delta(_.cc_open_date.cast("date"), "day"))
Out[14]: 
┏━━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━┓
┃ cc_open_datedate_regdate_diff ┃
┡━━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━┩
│ stringdateint64     │
├──────────────┼────────────┼───────────┤
│ 2012-09-122013-09-13366 │
│ 2003-08-312005-12-31

Replies: 1 comment 12 replies

Comment options

You must be logged in to vote
12 replies
@gforsyth
Comment options

@YCat33
Comment options

@gforsyth
Comment options

@gforsyth
Comment options

Answer selected by cpcloud
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants