Skip to content

Commit aad429c

Browse files
authored
Map CPS farm income to farm operations (#828)
1 parent c52d83d commit aad429c

3 files changed

Lines changed: 70 additions & 1 deletion

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Map CPS farm self-employment income to farm operations income.

policyengine_us_data/datasets/cps/cps.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -927,7 +927,7 @@ def add_personal_income_variables(cps: h5py.File, person: DataFrame, year: int):
927927
1 - p["taxable_interest_fraction"]
928928
)
929929
cps["self_employment_income"] = person.SEMP_VAL
930-
cps["farm_income"] = person.FRSE_VAL
930+
cps["farm_operations_income"] = person.FRSE_VAL
931931
cps["qualified_dividend_income"] = (
932932
person.DIV_VAL * (p["qualified_dividend_fraction"])
933933
)
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
import numpy as np
2+
import pandas as pd
3+
4+
from policyengine_us_data.datasets.cps.cps import add_personal_income_variables
5+
6+
7+
def _minimal_person_income_frame() -> pd.DataFrame:
8+
columns = [
9+
"WSAL_VAL",
10+
"HRSWK",
11+
"A_HRS1",
12+
"INT_VAL",
13+
"SEMP_VAL",
14+
"FRSE_VAL",
15+
"DIV_VAL",
16+
"RNT_VAL",
17+
"RESNSS1",
18+
"RESNSS2",
19+
"SS_VAL",
20+
"A_AGE",
21+
"UC_VAL",
22+
"LKWEEKS",
23+
"PNSN_VAL",
24+
"ANN_VAL",
25+
"DST_SC1",
26+
"DST_VAL1",
27+
"DST_SC2",
28+
"DST_VAL2",
29+
"DST_SC1_YNG",
30+
"DST_VAL1_YNG",
31+
"DST_SC2_YNG",
32+
"DST_VAL2_YNG",
33+
"OI_OFF",
34+
"OI_VAL",
35+
"CSP_VAL",
36+
"PAW_VAL",
37+
"SSI_VAL",
38+
"RETCB_VAL",
39+
"CAP_VAL",
40+
"WICYN",
41+
"VET_VAL",
42+
"WC_VAL",
43+
"DIS_VAL1",
44+
"DIS_SC1",
45+
"DIS_VAL2",
46+
"DIS_SC2",
47+
"CHSP_VAL",
48+
"PHIP_VAL",
49+
"POTC_VAL",
50+
"PMED_VAL",
51+
"MCARE",
52+
"PEMCPREM",
53+
]
54+
person = pd.DataFrame({column: [0.0, 0.0] for column in columns})
55+
person["A_AGE"] = [30, 45]
56+
person["LKWEEKS"] = [0, 0]
57+
return person
58+
59+
60+
def test_add_personal_income_variables_maps_farm_self_employment_to_operations():
61+
person = _minimal_person_income_frame()
62+
person["FRSE_VAL"] = [1_000.0, -500.0]
63+
cps = {}
64+
65+
add_personal_income_variables(cps, person, 2024)
66+
67+
np.testing.assert_array_equal(cps["farm_operations_income"], [1_000.0, -500.0])
68+
assert "farm_income" not in cps

0 commit comments

Comments
 (0)