policyengine 3.1.7__py3-none-any.whl → 3.1.8__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -40,14 +40,37 @@ class PolicyEngineUKDataset(Dataset):
40
40
  self.load()
41
41
 
42
42
  def save(self) -> None:
43
- """Save dataset to HDF5 file."""
43
+ """Save dataset to HDF5 file.
44
+
45
+ Converts object columns to categorical dtype to avoid slow pickle serialization.
46
+ """
44
47
  filepath = Path(self.filepath)
45
48
  if not filepath.parent.exists():
46
49
  filepath.parent.mkdir(parents=True, exist_ok=True)
50
+
51
+ # Convert DataFrames and optimize object columns to categorical
52
+ person_df = pd.DataFrame(self.data.person)
53
+ benunit_df = pd.DataFrame(self.data.benunit)
54
+ household_df = pd.DataFrame(self.data.household)
55
+
56
+ # Convert object columns to categorical to avoid pickle serialization
57
+ for col in person_df.columns:
58
+ if person_df[col].dtype == "object":
59
+ person_df[col] = person_df[col].astype("category")
60
+
61
+ for col in benunit_df.columns:
62
+ if benunit_df[col].dtype == "object":
63
+ benunit_df[col] = benunit_df[col].astype("category")
64
+
65
+ for col in household_df.columns:
66
+ if household_df[col].dtype == "object":
67
+ household_df[col] = household_df[col].astype("category")
68
+
47
69
  with pd.HDFStore(filepath, mode="w") as store:
48
- store["person"] = pd.DataFrame(self.data.person)
49
- store["benunit"] = pd.DataFrame(self.data.benunit)
50
- store["household"] = pd.DataFrame(self.data.household)
70
+ # Use format='table' to support categorical dtypes
71
+ store.put("person", person_df, format="table")
72
+ store.put("benunit", benunit_df, format="table")
73
+ store.put("household", household_df, format="table")
51
74
 
52
75
  def load(self) -> None:
53
76
  """Load dataset from HDF5 file into this instance."""
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: policyengine
3
- Version: 3.1.7
3
+ Version: 3.1.8
4
4
  Summary: A package to conduct policy analysis using PolicyEngine tax-benefit models.
5
5
  Author-email: PolicyEngine <hello@policyengine.org>
6
6
  License: GNU AFFERO GENERAL PUBLIC LICENSE
@@ -1,5 +1,5 @@
1
1
  policyengine/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- policyengine/__pycache__/__init__.cpython-313.pyc,sha256=QdDnJpEU322F2GyH3GCCTbAoQy1XElYycMgEbuzy5Lw,175
2
+ policyengine/__pycache__/__init__.cpython-313.pyc,sha256=LQBTMmPPnJo-w-7_mvuE542bVf07bu1ONsDcLBRHLH8,175
3
3
  policyengine/core/__init__.py,sha256=KBVhkqzkvjWLDDwk96vquQKL63ZFuLen5AzBOBnO9pg,912
4
4
  policyengine/core/dataset.py,sha256=iJr9-J6w11uMRYy3EEJO9Gveku1m71AA1yzeo-0SiCs,16094
5
5
  policyengine/core/dataset_version.py,sha256=6KeFCRGQto_Yyl4QY4Vo2JFythjaXrNAOHQiwRGESyM,378
@@ -20,7 +20,7 @@ policyengine/tax_benefit_models/uk.py,sha256=HzAG_dORmsj1NJ9pd9WrqwgZPe9DUDrZ1wV
20
20
  policyengine/tax_benefit_models/us.py,sha256=G51dAmHo8NJLb2mnbne6iO5eNaatCGUd_2unvawwF84,946
21
21
  policyengine/tax_benefit_models/uk/__init__.py,sha256=AiA74iED5FEryvUCMfVZi6pYDYuTfQcj9B01h8J5xFA,1105
22
22
  policyengine/tax_benefit_models/uk/analysis.py,sha256=O4eYJYF7tsgiuLuiWMU0OXq7ss6U8-vzlg6nC2U8sgU,3175
23
- policyengine/tax_benefit_models/uk/datasets.py,sha256=-lmj4eG2my2GGmMMkxI1iXobGQW5irBgylEwyV0xU6c,8039
23
+ policyengine/tax_benefit_models/uk/datasets.py,sha256=_puLrvNo700HFv17TLGXufXRFcrLS9-pBVjYwp1VFac,8989
24
24
  policyengine/tax_benefit_models/uk/model.py,sha256=djCLLBeik9ZGFqe5WXUNVcu1JXjh0U8MXakvncasUj0,9754
25
25
  policyengine/tax_benefit_models/uk/outputs.py,sha256=2mYLwQW4QNvrOHtHfm_ACqE9gbmuLxvcCyldRU46s0o,3543
26
26
  policyengine/tax_benefit_models/us/__init__.py,sha256=zP-UUQqOc9g0ymyHkweJdi4RVXQDKSR6SUxavUKvV0s,1101
@@ -32,8 +32,8 @@ policyengine/utils/__init__.py,sha256=1X-VYAWLyB9A0YRHwsGWrqQHns1WfeZ7ISC6DMU5my
32
32
  policyengine/utils/dates.py,sha256=HnAqyl8S8EOYp8ibsnMTmECYoDWCSqwL-7A2_qKgxSc,1510
33
33
  policyengine/utils/parametric_reforms.py,sha256=4P3U39-4pYTU4BN6JjgmVLUkCkBhRfZJ6UIWTlsjyQE,1155
34
34
  policyengine/utils/plotting.py,sha256=ZAzTWz38vIaW0c3Nt4Un1kfrNoXLyHCDd1pEJIlsRg4,5335
35
- policyengine-3.1.7.dist-info/licenses/LICENSE,sha256=hIahDEOTzuHCU5J2nd07LWwkLW7Hko4UFO__ffsvB-8,34523
36
- policyengine-3.1.7.dist-info/METADATA,sha256=stN3kD7499L_CWLa2RQwzpb_GYtJ8kC5RiDIY-1Tpww,45889
37
- policyengine-3.1.7.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
38
- policyengine-3.1.7.dist-info/top_level.txt,sha256=_23UPobfkneHQkpJ0e0OmDJfhCUfoXj_F2sTckCGOH4,13
39
- policyengine-3.1.7.dist-info/RECORD,,
35
+ policyengine-3.1.8.dist-info/licenses/LICENSE,sha256=hIahDEOTzuHCU5J2nd07LWwkLW7Hko4UFO__ffsvB-8,34523
36
+ policyengine-3.1.8.dist-info/METADATA,sha256=h0r-m8cflbRqVtwajLnbgxmrKmowdeWUpXHVwLRLIGw,45889
37
+ policyengine-3.1.8.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
38
+ policyengine-3.1.8.dist-info/top_level.txt,sha256=_23UPobfkneHQkpJ0e0OmDJfhCUfoXj_F2sTckCGOH4,13
39
+ policyengine-3.1.8.dist-info/RECORD,,