Skip to content

bug/BIPOIType and BIWaitingPeriodType loaded incorrectly #1800

@vinulw

Description

@vinulw
  • get_exposure_data expects the input locations file BIPOIType and BIWaitingPeriodType to be int(3)
  • if these columns are present in the location file they are not loaded in as int which throws an error

This is particularly an issue on the Platform where the loss_generation_task throws the following error when loading a locations file:

  File "/home/worker/.local/lib/python3.12/site-packages/oasislmf/computation/generate/losses.py", line 325, in run
    exposure_data = get_exposure_data(self, add_internal_col=True)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/worker/.local/lib/python3.12/site-packages/oasislmf/utils/data.py", line 872, in get_exposure_data
    prepare_oed_exposure(exposure_data)
  File "/home/worker/.local/lib/python3.12/site-packages/oasislmf/utils/data.py", line 765, in prepare_oed_exposure
    exposure_data.location.dataframe = prepare_location_df(exposure_data.location.dataframe)
                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/worker/.local/lib/python3.12/site-packages/oasislmf/utils/data.py", line 786, in prepare_location_df
    location_df[field_type['type_col']] = location_df[field_type['type_col']].fillna(field_type['type_value'])
                                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/worker/.local/lib/python3.12/site-packages/pandas/core/generic.py", line 7368, in fillna
    new_data = self._mgr.fillna(
               ^^^^^^^^^^^^^^^^^
  File "/home/worker/.local/lib/python3.12/site-packages/pandas/core/internals/base.py", line 186, in fillna
    return self.apply_with_block(
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/worker/.local/lib/python3.12/site-packages/pandas/core/internals/managers.py", line 363, in apply
    applied = getattr(b, f)(**kwargs)
              ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/worker/.local/lib/python3.12/site-packages/pandas/core/internals/blocks.py", line 2407, in fillna
    new_values = self.values.fillna(value=value, method=None, limit=limit)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/worker/.local/lib/python3.12/site-packages/pandas/core/arrays/_mixins.py", line 376, in fillna
    self._validate_setitem_value(value)
  File "/home/worker/.local/lib/python3.12/site-packages/pandas/core/arrays/categorical.py", line 1590, in _validate_setitem_value
    return self._validate_scalar(value)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/worker/.local/lib/python3.12/site-packages/pandas/core/arrays/categorical.py", line 1615, in _validate_scalar
    raise TypeError(
TypeError: Cannot setitem on a Categorical with a new category (3), set the categories first

Full worker.log

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

Projects

Status

Done

Relationships

None yet

Development

No branches or pull requests

Issue actions