Add implementation of df.residual