def _estimateByearMedian(row, buildings, minRank=MIN_RANK): """Compute the missing construction year as the median of all neighbours. Returns the estimated construction year""" N = _getNeighbours(row["neighbours"], buildings, row.name) if len(N) >= 1: estimatedYear = N.bja.median() if estimatedYear > 0 and not np.isnan(estimatedYear): year = estimatedYear else: year = np.nan return year else: np.nan
def _estimateByearRank(row, buildings, minRank=MIN_RANK): """Compute the missing construction year by ranking all neighbours based on their attributes and euclidean distance. Returns the estimated construction year""" N = _getNeighbours(row["neighbours"], buildings, row.name) if MIN_RANK < 1: N = N.dropna() if len(N) >= 1: if min(N.loc[:,"rank"]) <= minRank: estimatedYear = N.loc[N.loc[:,"rank"] == min(N.loc[:,"rank"]), "bja"].tolist() estimatedYear = estimatedYear[0] if estimatedYear > 0: year = estimatedYear else: year = np.nan else: year = np.nan return year else: return np.nan