def normalized_current_year()

in fclib/fclib/feature_engineering/feature_utils.py [0:0]


def normalized_current_year(datetime_col, min_year, max_year):
    """
    Temporal feature indicating the position of the year of a record in the
    entire time period under consideration, normalized to be between 0 and 1.
    
    Args:
        datetime_col: Datetime column.
        min_year: minimum value of year.
        max_year: maximum value of year.
    
    Returns:
        float: the position of the current year in the min_year:max_year range
    """
    year = datetime_col.dt.year

    if max_year != min_year:
        current_year = (year - min_year) / (max_year - min_year)
    else:
        current_year = pd.Series([0 for x in range(len(datetime_col))])

    return current_year