Skip to content

Commit

Permalink
test: float conversion error check
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobdadams committed Jul 31, 2023
1 parent d087ac9 commit fbac445
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tests/test_transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,18 @@ def test_switch_to_nullable_int_casts_string_field_with_empty_string(self):

tm.assert_frame_equal(retyped_df, test_df)

def test_switch_to_nullable_int_raises_on_uncastable_text(self):
df = pd.DataFrame({
'a': [1, 2, np.nan],
'b': [1.1, 1.2, 'foo'],
})

with pytest.raises(
TypeError,
match=re.escape('Cannot convert one or more fields to nullable ints. Check for non-int/non-np.nan values.')
):
retyped_df = palletjack.transform.DataCleaning.switch_to_nullable_int(df, ['a', 'b'])


class TestFloatFixing:

Expand Down

0 comments on commit fbac445

Please sign in to comment.