Skip to content

Instantly share code, notes, and snippets.

@joshreini1
Last active March 1, 2023 16:18
Show Gist options
  • Save joshreini1/2b8c034a1fb2aa62f5ce3bfe1e55a1b1 to your computer and use it in GitHub Desktop.
Save joshreini1/2b8c034a1fb2aa62f5ce3bfe1e55a1b1 to your computer and use it in GitHub Desktop.
# add data splits to the collection we just created
year_begin = 2014
year_end = 2016 # exclusive
states = ['CA', 'NY']
for year in range(year_begin, year_end):
for state in states:
tru.add_data_split(f'{year}-{state}',
pre_data = data[year][state]['data_preprocessed'].\
drop('Sex', axis = 1), # drop sex from pre-data
post_data = data[year][state]['data_postprocessed'].\
drop(['Sex_Female','Sex_Male'], axis = 1), # drop sex from post-data
label_data = data[year][state]['label'],
extra_data_df = data[year][state]['extra_data'].\
reset_index(drop=True).\
join(data[year][state]['data_preprocessed']['Sex'].reset_index(drop=True)), # add sex to extra data
split_type = "all")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment