switch_model/tools/graph/main.py
def build_year(self, df, build_year_col="build_year"):
        """
        Replaces all the build years that aren't a period with the value "Pre-existing".
        """
        # Get list of valid periods
        periods = self.tools.get_dataframe("periods", from_inputs=True)["INVESTMENT_PERIOD"].astype("str")
        df = df.copy()  # Make copy to not modify source
        df[build_year_col] = df[build_year_col].apply(
            lambda b: str(b) if str(b) in periods.values else "Pre-existing"
        ).astype("category")
        return df

        Replaces all the build years that aren't a period with the value "Pre-existing".
        
Replaces all the build years that aren't a period with the value "Pre-existing".
Replaces all the build years that aren ' t a period with the value " Pre - existing " .
def build_year(self, df, build_year_col="build_year"):
        periods = self.tools.get_dataframe("periods", from_inputs=True)["INVESTMENT_PERIOD"].astype("str")
        df = df.copy()  
        df[build_year_col] = df[build_year_col].apply(
            lambda b: str(b) if str(b) in periods.values else "Pre-existing"
        ).astype("category")
        return df
def build_year ( self , df , build_year_col = "build_year" ) : periods = self . tools . get_dataframe ( "periods" , from_inputs = True ) [ "INVESTMENT_PERIOD" ] . astype ( "str" ) df = df . copy ( ) df [ build_year_col ] = df [ build_year_col ] . apply ( lambda b : str ( b ) if str ( b ) in periods . values else "Pre-existing" ) . astype ( "category" ) return df
Replaces all the build years that aren't a period with the value "Pre-existing".
Replaces all the build years that aren ' t a period with the value " Pre - existing " .
"""
        Replaces all the build years that aren't a period with the value "Pre-existing".
        """ # Get list of valid periods # Make copy to not modify source
self
df
build_year_col