Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug] merge_nets fails if net2 has additional dataframes #2321

Open
6 tasks done
KS-HTK opened this issue Jun 28, 2024 · 1 comment
Open
6 tasks done

[bug] merge_nets fails if net2 has additional dataframes #2321

KS-HTK opened this issue Jun 28, 2024 · 1 comment
Assignees
Labels

Comments

@KS-HTK
Copy link
Collaborator

KS-HTK commented Jun 28, 2024

Bug report checklis

  • Searched the issues page for similar reports

  • Read the relevant sections of the documentation

  • Browse the tutorials and tests for usefull code snippets and examples of use

  • Reproduced the issue after updating with pip install --upgrade pandapower (or git pull)

  • Tried basic troubleshooting (if a bug/error) like restarting the interpreter and checking the pythonpath

Reproducible Example

# merge_nets issue minimal example
from pandapower.toolbox import merge_nets
from pandapower.networks import mv_oberrhein
from pandas import DataFrame
net = mv_oberrhein()
net2 = mv_oberrhein()

net2["example"] = DataFrame({"a": [1, 2, 3], "b": [4, 5, 6]})

new_net = merge_nets(net, net2, validate=False)

Issue Description and Traceback

If the second network in passed to the merge_nets function has a DataFrame that is not present within the first network the merge_nets function fails. This is because the check to determin if a DataFrame needs to be reindexed takes all DataFrames from the second network (with some exceptions e.g. key starts with _ or res_) and tries to verify that no index of net2[key] is in net[key].index but if net[key] does not exist it crashes.

Expected Behavior

OPTIONAL: A warning that a user Created DataFrame was encountered and references within might not be updated correctly.
The DataFrame that is not present should be merged to the output network without issue as it does not have any overlap with the first network.

Installed Versions

  • python version: 3.12
  • pandas version: 2.2.1
  • networkx version: 3.2.1
  • scipy version: 1.12.0
  • numpy version: 1.26.4
  • packaging version: 24.0
  • tqdm version: 4.66.2
  • deepdiff version: 6.7.1
  • Operating System name/version: Windows 10 Enterprise 22H2

Label

  • Relevant labels are selected
@KS-HTK KS-HTK added the bug label Jun 28, 2024
@KS-HTK KS-HTK self-assigned this Jun 28, 2024
KS-HTK pushed a commit to KS-HTK/pandapower that referenced this issue Jul 1, 2024
… present in net before accessing its index.

closes issue e2nIEE#2321
@KS-HTK KS-HTK closed this as completed Jul 1, 2024
@KS-HTK
Copy link
Collaborator Author

KS-HTK commented Jul 3, 2024

A test should be added to test this, both ways a df in net1 that is not in net2 and vice versa.

@KS-HTK KS-HTK reopened this Jul 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant