Skip to content

Commit

Permalink
changes for deprecation warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
jdebacker committed Aug 23, 2024
1 parent b620a7c commit dcfb851
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 17 deletions.
1 change: 0 additions & 1 deletion ogusa/calibrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from taxcalc import Records
from ogcore import txfunc, demographics
from ogcore.utils import safe_read_pickle, mkdirs
import pkg_resources


class Calibration:
Expand Down
7 changes: 4 additions & 3 deletions ogusa/get_micro_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import numpy as np
import os
import pickle
import pkg_resources
import importlib.metadata
from ogcore import utils
from ogusa.constants import DEFAULT_START_YEAR, TC_LAST_YEAR

Expand Down Expand Up @@ -183,7 +183,7 @@ def get_data(
del results

# Pull Tax-Calc version for reference
taxcalc_version = pkg_resources.get_distribution("taxcalc").version
taxcalc_version = importlib.metadata.version("taxcalc")

return micro_data_dict, taxcalc_version

Expand Down Expand Up @@ -263,7 +263,8 @@ def taxcalc_advance(
"total_tax_liab": calc1.array("combined"),
"payroll_tax_liab": calc1.array("payrolltax"),
"etr": (
(calc1.array("combined") - calc1.array("ubi")) / market_income
(calc1.array("combined") - calc1.array("ubi"))
/ np.maximum(market_income, 1)
),
"year": calc1.current_year * np.ones(length),
"weight": calc1.array("s006"),
Expand Down
24 changes: 11 additions & 13 deletions ogusa/psid_data_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# This is the case when a separate script is calling this function in
# this module
CURDIR = os.path.split(os.path.abspath(__file__))[0]
except:
except NameError:
# This is the case when a Jupyter notebook is calling this function
CURDIR = os.getcwd()
output_fldr = "io_files"
Expand Down Expand Up @@ -54,11 +54,13 @@ def prep_data(
# SRC sample families have 1968 family interview numbers less than 3000
raw_df = raw_df[raw_df["ID1968"] < 3000].copy()

raw_df["relation.head"][
(raw_df["year"] < 1983) & (raw_df["relation.head"] == 1)
raw_df.loc[
raw_df.index[(raw_df["year"] < 1983) & (raw_df["relation.head"] == 1)],
"relation.head",
] = 10
raw_df["relation.head"][
(raw_df["year"] < 1983) & (raw_df["relation.head"] == 2)
raw_df.loc[
raw_df.index[(raw_df["year"] < 1983) & (raw_df["relation.head"] == 2)],
"relation.head",
] = 20
head_df = raw_df.loc[
raw_df.index[
Expand Down Expand Up @@ -123,7 +125,7 @@ def prep_data(
# pull series of interest using pandas_datareader
fred_data = web.DataReader(["CPIAUCSL"], "fred", start, end)
# Make data annual by averaging over months in year
fred_data = fred_data.resample("A").mean()
fred_data = fred_data.resample("YE").mean()
fred_data["year_data"] = fred_data.index.year
psid_df2 = psid_df.merge(fred_data, how="left", on="year_data")
psid_df = psid_df2
Expand Down Expand Up @@ -275,15 +277,11 @@ def prep_data(
# Backfill and then forward fill variables that are constant over time
# within hhid
for item in PSID_CONSTANT_VARS:
rebalanced_data[item] = rebalanced_data.groupby("hh_id")[item].fillna(
method="bfill"
)
rebalanced_data[item] = rebalanced_data.groupby("hh_id")[item].fillna(
method="ffill"
)
rebalanced_data[item] = rebalanced_data.groupby("hh_id")[item].bfill()
rebalanced_data[item] = rebalanced_data.groupby("hh_id")[item].ffill()

### NOTE: we seem to get some cases where the marital status is not constant
# despite trying to set up the indentifcation of a household such that it
# despite trying to set up the identification of a household such that it
# has to be. Why this is happening needs to be checked.

# Fill in year by doing a cumulative counter within each hh_id and then
Expand Down
1 change: 1 addition & 0 deletions ogusa/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def read_cbo_forecast():
& (pd.isnull(df["Unnamed: 2"]))
)
]
# df.fillna(value=np.nan, inplace=True)
df.fillna(value="", inplace=True)
df["full_var_name"] = (
df["Unnamed: 0"] + df["Unnamed: 1"] + df["Unnamed: 2"]
Expand Down

0 comments on commit dcfb851

Please sign in to comment.