Code Duplication    Length = 32-32 lines in 2 locations

src/egon/data/datasets/electricity_demand_timeseries/cts_buildings.py 2 locations

@@ 1098-1129 (lines=32) @@
1095
    )
1096
1097
1098
def cts_heat():
1099
    """
1100
    Calculate cts electricity demand share of hvmv substation profile
1101
     for buildings.
1102
    """
1103
1104
    with db.session_scope() as session:
1105
        cells_query = session.query(CtsBuildings)
1106
1107
    df_cts_buildings = pd.read_sql(
1108
        cells_query.statement, cells_query.session.bind, index_col=None
1109
    )
1110
1111
    df_demand_share_2035 = calc_building_demand_profile_share(
1112
        df_cts_buildings, scenario="eGon2035", sector="heat"
1113
    )
1114
    df_demand_share_100RE = calc_building_demand_profile_share(
1115
        df_cts_buildings, scenario="eGon100RE", sector="heat"
1116
    )
1117
1118
    df_demand_share = pd.concat(
1119
        [df_demand_share_2035, df_demand_share_100RE],
1120
        axis=0,
1121
        ignore_index=True,
1122
    )
1123
    # TODO workaround
1124
    df_demand_share = df_demand_share.reset_index().rename(
1125
        columns={"index": "serial"}
1126
    )
1127
1128
    write_table_to_postgres(
1129
        df_demand_share, EgonCtsHeatDemandBuildingShare, drop=True
1130
    )
1131
1132
@@ 1063-1094 (lines=32) @@
1060
    )
1061
1062
1063
def cts_electricity():
1064
    """
1065
    Calculate cts electricity demand share of hvmv substation profile
1066
     for buildings.
1067
    """
1068
1069
    with db.session_scope() as session:
1070
        cells_query = session.query(CtsBuildings)
1071
1072
    df_cts_buildings = pd.read_sql(
1073
        cells_query.statement, cells_query.session.bind, index_col=None
1074
    )
1075
1076
    df_demand_share_2035 = calc_building_demand_profile_share(
1077
        df_cts_buildings, scenario="eGon2035", sector="electricity"
1078
    )
1079
    df_demand_share_100RE = calc_building_demand_profile_share(
1080
        df_cts_buildings, scenario="eGon100RE", sector="electricity"
1081
    )
1082
1083
    df_demand_share = pd.concat(
1084
        [df_demand_share_2035, df_demand_share_100RE],
1085
        axis=0,
1086
        ignore_index=True,
1087
    )
1088
    # TODO workaround
1089
    df_demand_share = df_demand_share.reset_index().rename(
1090
        columns={"index": "serial"}
1091
    )
1092
1093
    write_table_to_postgres(
1094
        df_demand_share, EgonCtsElectricityDemandBuildingShare, drop=True
1095
    )
1096
1097