Skip to content

Commit 81b74b0

Browse files
ganevgvproost
authored andcommitted
TST: add test for df comparing strings to numbers raises ValueError (pandas-dev#29535)
1 parent 95a45b9 commit 81b74b0

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

pandas/tests/frame/test_operators.py

+10
Original file line numberDiff line numberDiff line change
@@ -530,6 +530,16 @@ def test_comp(func):
530530
test_comp(operator.ge)
531531
test_comp(operator.le)
532532

533+
def test_strings_to_numbers_comparisons_raises(self, compare_operators_no_eq_ne):
534+
# GH 11565
535+
df = DataFrame(
536+
{x: {"x": "foo", "y": "bar", "z": "baz"} for x in ["a", "b", "c"]}
537+
)
538+
539+
f = getattr(operator, compare_operators_no_eq_ne)
540+
with pytest.raises(TypeError):
541+
f(df, 0)
542+
533543
def test_comparison_protected_from_errstate(self):
534544
missing_df = tm.makeDataFrame()
535545
missing_df.iloc[0]["A"] = np.nan

0 commit comments

Comments
 (0)