... patsy: functions


Here's the example of the custom function being used.

import patsy as ps
import numpy as np

def date_to_num(date_col):
    return (date_col - date_col.min()).dt.days

y, X = ps.dmatrices("n_born ~ date_to_num(date) + np.log(yday)", df_clean)

Beware the dangers of stateful transformations though. See the documentation for the long story.

Feedback? See an issue? Something unclear? Feel free to mention it here.

If you want to be kept up to date, consider signing up for the newsletter.