Skip to content

Conversation

@vahid-ahmadi
Copy link
Collaborator

@vahid-ahmadi vahid-ahmadi commented Jan 22, 2026

Summary

  • Fix TypeError in uprate_rent when region.values.astype(str) returns a pandas StringArray instead of a numpy array
  • The ParameterNodeAtInstant.__getitem__ expects a numpy.ndarray for vectorial lookup, but pandas StringArray is not hashable

Problem

When running microsimulations, the following error occurs:

TypeError: unhashable type: 'StringArray'

This happens in economic_assumptions.py line 164-165 where region.values.astype(str) returns a pandas StringArray which cannot be used as a key in the parameter lookup.

CI Test Failures (Unrelated to this PR)

The CI test failures are NOT caused by this PR. They are due to a dependency version conflict that occurred after the last successful main branch CI run.

Evidence:

  • Main branch CI passed 21 hours ago (2026-01-21 11:55 UTC)
  • This PR CI failed today (2026-01-22 09:16 UTC)
  • All tests pass locally on both main branch and this PR branch

Root cause:
The CI workflow runs uv pip install policyengine --system which now pulls in:

  • pandas==3.0.0 (newly released)
  • microdf-python==1.1.2

This combination is broken - microdf 1.1.2 is incompatible with pandas 3.0.0:

AttributeError: 'Series' object has no attribute 'set_weights'

The region.values.astype(str) returns a pandas StringArray which is
not hashable and cannot be used with ParameterNodeAtInstant.__getitem__.
Converting to np.array() ensures compatibility with the vectorial
parameter lookup.

Fixes TypeError: unhashable type: 'StringArray' when running
microsimulations.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants