Skip to content

Commit fcb9f4e

Browse files
include_groups=False in data_transformations .apply (#531)
1 parent cf8178d commit fcb9f4e

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

CHANGELOG.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
**4.2.5 - 07/18/25**
2+
3+
- Hush FutureWarnings: add include_groups=False to apply call in StratifiedObservation
4+
15
**4.2.4 - 07/16/25**
26

37
- Support pinning of vivarium_build_utils; pin vivarium_build_utils>=1.1.0,<2.0.0

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
"layered_config_tree>=3.2.0",
4848
"loguru",
4949
"numpy<2.0.0",
50-
"pandas",
50+
"pandas>=2.2.0",
5151
"scipy",
5252
"tables",
5353
"risk_distributions>=2.0.11",

src/vivarium_public_health/population/data_transformations.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,21 +54,27 @@ def assign_demographic_proportions(
5454

5555
population_data["P(sex, location, age| year)"] = (
5656
population_data.groupby("year_start", as_index=False)
57-
.apply(lambda sub_pop: sub_pop[["value"]] / sub_pop["value"].sum())
57+
.apply(
58+
lambda sub_pop: sub_pop[["value"]] / sub_pop["value"].sum(), include_groups=False
59+
)
5860
.reset_index(level=0)["value"]
5961
.fillna(0.0)
6062
)
6163

6264
population_data["P(sex, location | age, year)"] = (
6365
population_data.groupby(["age", "year_start"], as_index=False)
64-
.apply(lambda sub_pop: sub_pop[["value"]] / sub_pop["value"].sum())
66+
.apply(
67+
lambda sub_pop: sub_pop[["value"]] / sub_pop["value"].sum(), include_groups=False
68+
)
6569
.reset_index(level=0)["value"]
6670
.fillna(0.0)
6771
)
6872

6973
population_data["P(age | year, sex, location)"] = (
7074
population_data.groupby(["year_start", "sex", "location"], as_index=False)
71-
.apply(lambda sub_pop: sub_pop[["value"]] / sub_pop["value"].sum())
75+
.apply(
76+
lambda sub_pop: sub_pop[["value"]] / sub_pop["value"].sum(), include_groups=False
77+
)
7278
.reset_index(level=0)["value"]
7379
.fillna(0.0)
7480
)

0 commit comments

Comments
 (0)