Cast the column to the correct type before assigning values #2371
+17
−8
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR removes many warnings:
FutureWarning: Setting an item of incompatible dtype is deprecated and will raise an error in a future version of pandas.
I see in
warnings (3.12, 2)
it too, but as an error:ERROR pandapower/test/plotting/test_geo.py - FutureWarning: Setting an item of incompatible dtype is deprecated and will raise an error in a future version of pandas. Value '[-2, -3]' has dtype incompatible with int32, please explicitly cast to a compatible dtype first.
Update 09.09.2024
What was done:
mv_oberrhein.py:76
Column
net.trafo["tap_pos"]
has values nan and this is float type, so astype("float64").from_ppc.py:336
branch_lookup.loc[is_impedance, "element"] = idx_impedance
although all masks
is_impedance [False False False False False False False]
andidx_impedance
represents an empty list, which changes the type from int64 to float64, so astype("float64").create.py:5990
moved line 5991 up to convert column to correct type before assignment
geo.py:556, test_iec60909_4.py:470
the value to set is a string or None, so the type is object
grid_modification.py:1217-1219
Since val can contain both string and numeric values, I define the column type based on the values.
grid_modification.py:1232-1233, 1399-1400, 1621-1622
Casting values to column type
net[table]"element"]