def _impute(df, observations, censorship, transform_in, transform_out):
 uncensored_mask = (df[censorship] == False)
 censored_mask = (df[censorship] == True)
 fit_params = stats.linregress(df['Zprelim'][uncensored_mask], transform_in(df[observations][uncensored_mask]))
 (slope, intercept) = fit_params[:2]
 df.loc[:, 'estimated'] = transform_out(((slope * df['Zprelim'][censored_mask]) + intercept))
 df.loc[:, 'final'] = numpy.where(df[censorship], df['estimated'], df[observations])
 return df

def _impute ( df , observations , censorship , transform_in , transform_out ) : uncensored_mask = ( df [ censorship ] == False ) censored_mask = ( df [ censorship ] == True ) fit_params = stats . linregress ( df [ 'Zprelim' ] [ uncensored_mask ] , transform_in ( df [ observations ] [ uncensored_mask ] ) ) ( slope , intercept ) = fit_params [ : 2 ] df . loc [ : , 'estimated' ] = transform_out ( ( ( slope * df [ 'Zprelim' ] [ censored_mask ] ) + intercept ) ) df . loc [ : , 'final' ] = numpy . where ( df [ censorship ] , df [ 'estimated' ] , df [ observations ] ) return df
executes the basic regression on order stat proceedure .