Calmcode - smoking: quantifying the effect

Quantifying the Effect

1 2 3 4 5 6 7

We can calculate the effect of smoking, while keeping the age in mind.

  .assign(age=lambda d: np.round(d['age'] / 10) * 10)
  .groupby(['smokes', 'age'])
  .agg(p=('alive', np.mean))
  .pivot(index='age', columns='smokes', values='p')
  .assign(diff=lambda d: d[0] - d[1])['diff'].mean())

It seems that we get a +3.45% bonus to living longer if we do not smoke, but it should be said that this effect won't be noticeable unless you are of old age.