recordlinkage/contrib/index/neighbourhoodblock/neighbourhoodblock_test.py
def incomplete_df_copy(df, nan_proportion=0.1):
            'copy of DataFrame with some cells set to NaN'
            nan_count = int(round(len(df) * nan_proportion))

            def with_nulls(vals):
                vals = vals.copy()
                vals.iloc[np.random.choice(
                    len(df), size=nan_count, replace=False)] = np.nan
                return vals

            return df.copy() if nan_count <= 0 else df.apply(with_nulls)
copy of DataFrame with some cells set to NaN
copy of DataFrame with some cells set to NaN
copy of DataFrame with some cells set to NaN
def incomplete_df_copy(df, nan_proportion=0.1):
            nan_count = int(round(len(df) * nan_proportion))
            def with_nulls(vals):
                vals = vals.copy()
                vals.iloc[np.random.choice(
                    len(df), size=nan_count, replace=False)] = np.nan
                return vals
            return df.copy() if nan_count <= 0 else df.apply(with_nulls)
def incomplete_df_copy ( df , nan_proportion = 0.1 ) : nan_count = int ( round ( len ( df ) * nan_proportion ) ) def with_nulls ( vals ) : vals = vals . copy ( ) vals . iloc [ np . random . choice ( len ( df ) , size = nan_count , replace = False ) ] = np . nan return vals return df . copy ( ) if nan_count <= 0 else df . apply ( with_nulls )
copy of DataFrame with some cells set to NaN
copy of DataFrame with some cells set to NaN
'copy of DataFrame with some cells set to NaN'
df
nan_proportion