Skip to content

Commit

Permalink
Additional Pandas v2.0 fixes (#922)
Browse files Browse the repository at this point in the history
  • Loading branch information
matt-graham authored Apr 4, 2023
1 parent e70a5d2 commit 9d93c77
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/tlo/methods/rti.py
Original file line number Diff line number Diff line change
Expand Up @@ -2390,7 +2390,7 @@ def rti_assign_injuries(self, number):
'Polytrauma': sum(i > 2 for i in injais) > 1,
'MAIS': max(injmais),
'Number_of_injuries': ninj}
inj_df = inj_df.append(new_row, ignore_index=True)
inj_df.loc[len(inj_df)] = new_row
# If person has an ISS score less than 15 they have a mild injury, otherwise severe
if new_row['ISS'] < 15:
severity_category.append('mild')
Expand Down
2 changes: 1 addition & 1 deletion tests/test_healthsystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -838,7 +838,7 @@ def apply(self, person_id, squeeze_factor):
}).unstack().fillna(0.0).astype(int)

assert summary_hsi_event['Number_By_Appt_Type_Code'].apply(pd.Series).sum().to_dict() == \
counts_of_appts_by_level.sum(axis=1, level=1).sum(axis=0).to_dict()
counts_of_appts_by_level.groupby(axis=1, level=1).sum().sum().to_dict()


@pytest.mark.slow
Expand Down
24 changes: 12 additions & 12 deletions tests/test_hiv_tb_scenarios.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,12 +162,12 @@ def test_check_tb_test_under_each_scenario(seed):
hiv_pos_person = 1
both_people = [hiv_neg_person, hiv_pos_person]

df.at[both_people, 'tb_inf'] = 'active'
df.at[both_people, 'tb_strain'] = 'ds'
df.at[both_people, 'tb_date_active'] = sim.date
df.at[both_people, 'tb_smear'] = True
df.at[both_people, 'age_exact_years'] = 20
df.at[both_people, 'age_years'] = 20
df.loc[both_people, 'tb_inf'] = 'active'
df.loc[both_people, 'tb_strain'] = 'ds'
df.loc[both_people, 'tb_date_active'] = sim.date
df.loc[both_people, 'tb_smear'] = True
df.loc[both_people, 'age_exact_years'] = 20
df.loc[both_people, 'age_years'] = 20

# set HIV status
df.at[hiv_neg_person, 'hv_inf'] = False
Expand Down Expand Up @@ -236,12 +236,12 @@ def test_check_tb_test_under_each_scenario(seed):
hiv_pos_person = 1
both_people = [hiv_neg_person, hiv_pos_person]

df.at[both_people, 'tb_inf'] = 'active'
df.at[both_people, 'tb_strain'] = 'ds'
df.at[both_people, 'tb_date_active'] = sim.date
df.at[both_people, 'tb_smear'] = True
df.at[both_people, 'age_exact_years'] = 20
df.at[both_people, 'age_years'] = 20
df.loc[both_people, 'tb_inf'] = 'active'
df.loc[both_people, 'tb_strain'] = 'ds'
df.loc[both_people, 'tb_date_active'] = sim.date
df.loc[both_people, 'tb_smear'] = True
df.loc[both_people, 'age_exact_years'] = 20
df.loc[both_people, 'age_years'] = 20
# set HIV status
df.at[hiv_neg_person, 'hv_inf'] = False
df.at[hiv_pos_person, 'hv_inf'] = True
Expand Down

0 comments on commit 9d93c77

Please sign in to comment.