Skip to content

Commit

Permalink
Updated rpy2 API calls in psid_data_setup.py
Browse files Browse the repository at this point in the history
  • Loading branch information
rickecon committed May 16, 2024
1 parent 28ea7b1 commit 2b622f3
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion ogusa/psid_data_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@
import datetime
from linearmodels import PanelOLS
from rpy2.robjects import r
from rpy2.robjects import conversion
from rpy2.robjects import default_converter
from rpy2.robjects import pandas2ri
from rpy2.robjects.packages import importr
from ogusa.constants import PSID_NOMINAL_VARS, PSID_CONSTANT_VARS


pandas2ri.activate()
pd.options.mode.chained_assignment = "raise"

Expand All @@ -34,7 +38,9 @@ def prep_data(data="psid1968to2015.RData"):
"""
# Read data from R into pandas dataframe
r["load"](os.path.join(CURDIR, "..", "data", "PSID", data))
raw_df = r("psid_df")
raw_r_df = r("psid_df")
with (default_converter + pandas2ri.converter).context():
raw_df = conversion.get_conversion().rpy2py(raw_r_df)

# Create unique identifier for each household
# note that will define a new household if head or spouse changes
Expand Down

0 comments on commit 2b622f3

Please sign in to comment.