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

KeyError in overlap handler #183

Closed
bl-young opened this issue Mar 19, 2025 · 1 comment · Fixed by #184
Closed

KeyError in overlap handler #183

bl-young opened this issue Mar 19, 2025 · 1 comment · Fixed by #184
Labels
Milestone

Comments

@bl-young
Copy link
Collaborator

df = stewicombo.combineInventoriesforFacilitiesinBaseInventory(
    base_inventory='TRI',
    inventory_dict = {'NEI': 2020,
                      'TRI': 2020,
                      'DMR': 2020,
                      'eGRID': 2020,
                      'GHGRP': 2020},
    download_if_missing=True
    )
Cell In[22], line 1
    df = df.drop(df_nans.index)

  File ~\.conda\envs\tiem_dev_latest\Lib\site-packages\pandas\core\frame.py:5581 in drop
    return super().drop(

  File ~\.conda\envs\tiem_dev_latest\Lib\site-packages\pandas\core\generic.py:4788 in drop
    obj = obj._drop_axis(labels, axis, level=level, errors=errors)

  File ~\.conda\envs\tiem_dev_latest\Lib\site-packages\pandas\core\generic.py:4830 in _drop_axis
    new_axis = axis.drop(labels, errors=errors)

  File ~\.conda\envs\tiem_dev_latest\Lib\site-packages\pandas\core\indexes\base.py:7070 in drop
    raise KeyError(f"{labels[mask].tolist()} not found in axis")

KeyError: '[381883, 381885, 381899, 381904, 381924, 381929, 381943, 381952, 381958, 381974, 381979, 381984, 381986, 382018, 382022, 382056, 382078, 382088, 382201, 382223, 382234, 382238, 382269, 382325, 382334, 382338, 382405, 382453, 382496, 382530, 382537, 382562, 382575, 382585] not found in axis'
@bl-young bl-young added the bug label Mar 19, 2025
@bl-young
Copy link
Collaborator Author

rows with nan are identified before running remove_nutrient_overlap_TRI, which resets the index, then when rows with nan are removed, if they are too close to the end it throws a KeyError. If they are not too close to the end the wrong rows get dropped.

@bl-young bl-young linked a pull request Mar 19, 2025 that will close this issue
@bl-young bl-young added this to the v1.2.0 milestone Mar 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant