importr('survival')
pandas2ri.activate()
coxph_ = r('coxph')
model = coxph_(Formula('Surv(time, outcome) ~ f1 + f2'), data=df, weights=
    df.num_in_group)
Fitting Survival Models in Python From Aggregate Data