Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions changelog_entry.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- bump: patch
changes:
changed:
- Bumped policyengine-core minimum version to 3.23.5 for pandas 3.0 compatibility
33 changes: 33 additions & 0 deletions policyengine_us_data/tests/test_pandas3_compatibility.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
"""Test pandas 3.0 compatibility.

This test verifies that policyengine-core 3.23.5+ correctly handles
pandas Series with StringDtype index when encoding enums.
"""

import numpy as np
import pandas as pd
import pytest

from policyengine_core.enums import Enum


class SampleEnum(Enum):
VALUE_A = "value_a"
VALUE_B = "value_b"


def test_enum_encode_with_pandas_series():
"""Test that Enum.encode works with pandas Series containing enum items.

In pandas 3.0, Series with StringDtype use label-based indexing by default.
This test verifies the fix in policyengine-core 3.23.5 that uses .iloc[0]
for positional access.
"""
enum_items = [SampleEnum.VALUE_A, SampleEnum.VALUE_B, SampleEnum.VALUE_A]
series = pd.Series(enum_items)

# This would fail with KeyError: 0 before the fix
encoded = SampleEnum.encode(series)

assert len(encoded) == 3
assert list(encoded) == [0, 1, 0]
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ classifiers = [
]
dependencies = [
"policyengine-us>=1.353.0",
"policyengine-core>=3.19.0",
"policyengine-core>=3.23.6",
"pandas>=2.3.1",
"requests>=2.25.0",
"tqdm>=4.60.0",
"microdf_python>=1.0.0",
"microdf_python>=1.2.1",
"setuptools>=60",
"microimpute>=1.1.4",
"pip-system-certs>=3.0",
Expand Down
20 changes: 9 additions & 11 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.