diff --git a/pandas/tests/dtypes/test_dtypes.py b/pandas/tests/dtypes/test_dtypes.py index abb29ce66fd34..30447de874aaa 100644 --- a/pandas/tests/dtypes/test_dtypes.py +++ b/pandas/tests/dtypes/test_dtypes.py @@ -1095,3 +1095,15 @@ def test_period_dtype_compare_to_string(): dtype = PeriodDtype(freq="M") assert (dtype == "period[M]") is True assert (dtype != "period[M]") is False + + +def test_compare_complex_dtypes(): + # GH 28050 + df = pd.DataFrame(np.arange(5).astype(np.complex128)) + msg = "'<' not supported between instances of 'complex' and 'complex'" + + with pytest.raises(TypeError, match=msg): + df < df.astype(object) + + with pytest.raises(TypeError, match=msg): + df.lt(df.astype(object))