src/ei_mcoe/ei_mcoe.py
def calc_agg_retire_date(retire_col, level):
    """Calculate a retirement age for the aggregated data.

    This function is used within the groupby.agg() method to calcualte an
    approporate retirement date for the given aggregation. It will only
    show a retirement date if all of the entities within the aggregation unit
    also have retirement dates (there is no None) in the list, seeing as an
    entity cannot be considered "retired" until all of its components are. As
    a result, when all entities do have a retirement date, the recorded date is
    that which is most recent.

    Args:
        retire_col(pd.Series): The retirement_date column as a series.

    Returns:
        datetime.Datetime: The date of the most recent retirement (or None) if
            one or more entities within the aggregation unit are have a
            retirement date of None.
    """
    # Create appropirate sub-unit name
    if level == 'plant-fuel':
        sub_lev = 'unit(s)'
    elif level == 'unit-fuel':
        sub_lev = 'generator(s)'
    # Make list out of retirement dates in groupby
    retire_list = retire_col.tolist()
    # Record a retirement data only if all entities in group have a retirement
    # date. Then, select the most recent date.
    if None not in retire_list:
        date = max(retire_list)
    else:
        none_val = 0
        for x in retire_list:
            if x is None:
                none_val += 1
        date = f"{len(retire_list)-none_val} of {len(retire_list)} {sub_lev} "
        "have a retirement date"
    return date
Calculate a retirement age for the aggregated data.

    This function is used within the groupby.agg() method to calcualte an
    approporate retirement date for the given aggregation. It will only
    show a retirement date if all of the entities within the aggregation unit
    also have retirement dates (there is no None) in the list, seeing as an
    entity cannot be considered "retired" until all of its components are. As
    a result, when all entities do have a retirement date, the recorded date is
    that which is most recent.

    Args:
        retire_col(pd.Series): The retirement_date column as a series.

    Returns:
        datetime.Datetime: The date of the most recent retirement (or None) if
            one or more entities within the aggregation unit are have a
            retirement date of None.
    
Calculate a retirement age for the aggregated data.
This function is used within the groupby.agg() method to calcualte an
approporate retirement date for the given aggregation. It will only
show a retirement date if all of the entities within the aggregation unit
also have retirement dates (there is no None) in the list, seeing as an
entity cannot be considered "retired" until all of its components are. As
a result, when all entities do have a retirement date, the recorded date is
that which is most recent.
Calculate a retirement age for the aggregated data . This function is used within the groupby . agg () method to calcualte an approporate retirement date for the given aggregation . It will only show a retirement date if all of the entities within the aggregation unit also have retirement dates ( there is no None ) in the list seeing as an entity cannot be considered " retired " until all of its components are . As a result when all entities do have a retirement date the recorded date is that which is most recent .
def calc_agg_retire_date(retire_col, level):
    if level == 'plant-fuel':
        sub_lev = 'unit(s)'
    elif level == 'unit-fuel':
        sub_lev = 'generator(s)'
    retire_list = retire_col.tolist()
    if None not in retire_list:
        date = max(retire_list)
    else:
        none_val = 0
        for x in retire_list:
            if x is None:
                none_val += 1
        date = f"{len(retire_list)-none_val} of {len(retire_list)} {sub_lev} "
    return date
def calc_agg_retire_date ( retire_col , level ) : if level == 'plant-fuel' : sub_lev = 'unit(s)' elif level == 'unit-fuel' : sub_lev = 'generator(s)' retire_list = retire_col . tolist ( ) if None not in retire_list : date = max ( retire_list ) else : none_val = 0 for x in retire_list : if x is None : none_val += 1 date = f"{len(retire_list)-none_val} of {len(retire_list)} {sub_lev} " "have a retirement date" return date
Calculate a retirement age for the aggregated data.
Calculate a retirement age for the aggregated data .
"""Calculate a retirement age for the aggregated data.

    This function is used within the groupby.agg() method to calcualte an
    approporate retirement date for the given aggregation. It will only
    show a retirement date if all of the entities within the aggregation unit
    also have retirement dates (there is no None) in the list, seeing as an
    entity cannot be considered "retired" until all of its components are. As
    a result, when all entities do have a retirement date, the recorded date is
    that which is most recent.

    Args:
        retire_col(pd.Series): The retirement_date column as a series.

    Returns:
        datetime.Datetime: The date of the most recent retirement (or None) if
            one or more entities within the aggregation unit are have a
            retirement date of None.
    """ # Create appropirate sub-unit name # Make list out of retirement dates in groupby # Record a retirement data only if all entities in group have a retirement # date. Then, select the most recent date. "have a retirement date"
The date of the most recent retirement (or None) if
one or more entities within the aggregation unit are have a
retirement date of None.
The date of the most recent retirement ( or None ) if one or more entities within the aggregation unit are have a retirement date of None .
datetime.Datetime
retire_col
The retirement_date column as a series.
The retirement_date column as a series .
level