Skip to content

Commit 4c68486

Browse files
committed
Fix pandas array read only error
1 parent 6beaf23 commit 4c68486

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

CHANGELOG.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
**1.2.6 - 01/05/26**
2+
3+
- Bugfix: Fix pandas array read only error when loading test data
4+
15
**1.2.5 - 01/02/26**
26

37
- Leverage vivarium_dependencies

tests/integration/conftest.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,8 @@ def split_sample_data_dir_state_edit(tmpdir_factory, split_sample_data_dir):
109109
# We do not filter by state for SSA
110110
if dataset_name != DatasetNames.SSA:
111111
# Add a state so we can filter for integration tests
112+
# Make a copy to avoid read-only categorical array error
113+
data = data.copy()
112114
state_column = [column for column in data.columns if "state" in column]
113115
data.loc[data.reset_index().index % 2 == 0, state_column] = STATE
114116
data.to_parquet(outdir / data_path.name)
@@ -208,6 +210,8 @@ def noised_sample_data_taxes_1040(config):
208210
def sample_data_decennial_census_state_edit():
209211
data = _load_sample_data(DATASETS.census.name)
210212
# Set half of the entries to the state we'll filter on
213+
# Make a copy to avoid read-only categorical array error
214+
data = data.copy()
211215
data.loc[data.reset_index().index % 2 == 0, DATASETS.census.state_column_name] = STATE
212216
return data
213217

@@ -216,6 +220,8 @@ def sample_data_decennial_census_state_edit():
216220
def sample_data_american_community_survey_state_edit():
217221
data = _load_sample_data(DATASETS.acs.name)
218222
# Set half of the entries to the state we'll filter on
223+
# Make a copy to avoid read-only categorical array error
224+
data = data.copy()
219225
data.loc[data.reset_index().index % 2 == 0, DATASETS.acs.state_column_name] = STATE
220226
return data
221227

@@ -224,6 +230,8 @@ def sample_data_american_community_survey_state_edit():
224230
def sample_data_current_population_survey_state_edit():
225231
data = _load_sample_data(DATASETS.cps.name)
226232
# Set half of the entries to the state we'll filter on
233+
# Make a copy to avoid read-only categorical array error
234+
data = data.copy()
227235
data.loc[data.reset_index().index % 2 == 0, DATASETS.cps.state_column_name] = STATE
228236
return data
229237

@@ -232,6 +240,8 @@ def sample_data_current_population_survey_state_edit():
232240
def sample_data_women_infants_and_children_state_edit():
233241
data = _load_sample_data(DATASETS.wic.name)
234242
# Set half of the entries to the state we'll filter on
243+
# Make a copy to avoid read-only categorical array error
244+
data = data.copy()
235245
data.loc[data.reset_index().index % 2 == 0, DATASETS.wic.state_column_name] = STATE
236246
return data
237247

@@ -240,6 +250,8 @@ def sample_data_women_infants_and_children_state_edit():
240250
def sample_data_taxes_w2_and_1099_state_edit():
241251
data = _load_sample_data(DATASETS.tax_w2_1099.name)
242252
# Set half of the entries to the state we'll filter on
253+
# Make a copy to avoid read-only categorical array error
254+
data = data.copy()
243255
data.loc[
244256
data.reset_index().index % 2 == 0, DATASETS.tax_w2_1099.state_column_name
245257
] = STATE

0 commit comments

Comments
 (0)