diff --git a/CHANGELOG.rst b/CHANGELOG.rst index cb2a62835..c06c4aba3 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -15,6 +15,7 @@ Change Log [upcoming release] - 2024-..-.. ------------------------------- +- [FIXED] cast the column to the correct type before assigning values - [FIXED] replacement for deprecated namespaces scipy.sparse.csc and scipy.sparse.csr - [FIXED] copy array element to standard python scalar - [REMOVED] python 3.8 support diff --git a/pandapower/converter/pypower/from_ppc.py b/pandapower/converter/pypower/from_ppc.py index 31775fd4d..b851934e7 100644 --- a/pandapower/converter/pypower/from_ppc.py +++ b/pandapower/converter/pypower/from_ppc.py @@ -333,6 +333,7 @@ def _from_ppc_branch(net, ppc, f_hz, **kwargs): branch_lookup.loc[is_line, "element_type"] = "line" branch_lookup.loc[is_trafo, "element"] = idx_trafo branch_lookup.loc[is_trafo, "element_type"] = "trafo" + branch_lookup["element"] = branch_lookup["element"].astype("float64") branch_lookup.loc[is_impedance, "element"] = idx_impedance branch_lookup.loc[is_impedance, "element_type"] = "impedance" return branch_lookup diff --git a/pandapower/create.py b/pandapower/create.py index 29be634e2..7e98c7954 100644 --- a/pandapower/create.py +++ b/pandapower/create.py @@ -5987,8 +5987,8 @@ def _set_value_if_not_nan(net, index, value, column, element_type, dtype=float64 if not column_exists: net[element_type].loc[:, column] = pd.Series( data=default_val, index=net[element_type].index) - net[element_type].at[index, column] = value try_astype(net[element_type], column, dtype) + net[element_type].at[index, column] = value elif column_exists: if _not_nan(default_val): net[element_type].at[index, column] = default_val diff --git a/pandapower/networks/mv_oberrhein.py b/pandapower/networks/mv_oberrhein.py index fd830b080..4b566f549 100644 --- a/pandapower/networks/mv_oberrhein.py +++ b/pandapower/networks/mv_oberrhein.py @@ -73,6 +73,7 @@ def mv_oberrhein(scenario="load", cosphi_load=0.98, cosphi_pv=1.0, include_subst net.sgen.q_mvar = np.tan(np.arccos(cosphi_pv)) * net.sgen.p_mw hv_trafos = net.trafo[net.trafo.sn_mva > 1].index + net.trafo["tap_pos"] = net.trafo["tap_pos"].astype("float64") if scenario == "load": net.load.scaling = 0.6 net.sgen.scaling = 0.0 diff --git a/pandapower/plotting/geo.py b/pandapower/plotting/geo.py index 4cf758169..36e673201 100644 --- a/pandapower/plotting/geo.py +++ b/pandapower/plotting/geo.py @@ -553,6 +553,7 @@ def convert_geodata_to_geojson( if not coords: continue ls = f'{{"coordinates": {coords}, "type": "LineString"}}' + ldf["geo"] = ldf["geo"].astype(object) ldf.geo.at[l_id] = ls if delete: diff --git a/pandapower/test/shortcircuit/test_iec60909_4.py b/pandapower/test/shortcircuit/test_iec60909_4.py index 351293434..2bd7b5a01 100644 --- a/pandapower/test/shortcircuit/test_iec60909_4.py +++ b/pandapower/test/shortcircuit/test_iec60909_4.py @@ -467,7 +467,8 @@ def test_detect_power_station_units(): detect_power_station_unit(net) assert np.all(net.gen.power_station_trafo.values[[0, 1]] == np.array([0, 1])) - net.gen.loc[:, 'power_station_trafo'] = None + net.gen["power_station_trafo"] = net.gen["power_station_trafo"].astype(object) + net.gen.loc[:, "power_station_trafo"] = None detect_power_station_unit(net, mode="trafo") assert np.all(net.gen.power_station_trafo.values[[0, 1]] == np.array([0, 1])) diff --git a/pandapower/toolbox/grid_modification.py b/pandapower/toolbox/grid_modification.py index 88af967e5..9652b2671 100644 --- a/pandapower/toolbox/grid_modification.py +++ b/pandapower/toolbox/grid_modification.py @@ -1245,9 +1245,9 @@ def replace_ext_grid_by_gen(net, ext_grids=None, gen_indices=None, slack=False, in_service=ext_grid.in_service, controllable=True, index=index) new_idx.append(idx) net.gen.loc[new_idx, "slack"] = slack - net.gen.loc[new_idx, existing_cols_to_keep] = net.ext_grid.loc[ - ext_grids, existing_cols_to_keep].values - + val = net.ext_grid.loc[ext_grids, existing_cols_to_keep].values + net.gen[existing_cols_to_keep] = net.gen[existing_cols_to_keep].astype(val.dtype) + net.gen.loc[new_idx, existing_cols_to_keep] = val _replace_group_member_element_type(net, ext_grids, "ext_grid", new_idx, "gen") # --- drop replaced ext_grids @@ -1260,7 +1260,8 @@ def replace_ext_grid_by_gen(net, ext_grids=None, gen_indices=None, slack=False, (net[table].element.isin(ext_grids))] if len(to_change): net[table].loc[to_change, "et"] = "gen" - net[table].loc[to_change, "element"] = new_idx + net[table].loc[to_change, "element"] = np.array( + new_idx, net[table]["element"].dtypes) # --- result data if net.res_ext_grid.shape[0]: @@ -1426,7 +1427,8 @@ def replace_gen_by_sgen(net, gens=None, sgen_indices=None, cols_to_keep=None, to_change = net[table].index[(net[table].et == "gen") & (net[table].element.isin(gens))] if len(to_change): net[table].loc[to_change, "et"] = "sgen" - net[table].loc[to_change, "element"] = new_idx + net[table].loc[to_change, "element"] = np.array( + new_idx, net[table]["element"].dtypes) # --- result data if net.res_gen.shape[0]: @@ -1647,7 +1649,9 @@ def replace_pq_elmtype(net, old_element_type, new_element_type, old_indices=None (net[table].element.isin(old_indices))] if len(to_change): net[table].loc[to_change, "et"] = new_element_type - net[table].loc[to_change, "element"] = new_idx + net[table].loc[to_change, "element"] = np.array( + new_idx, net[table]["element"].dtypes) + # --- result data if net["res_" + old_element_type].shape[0]: