API: flex comparisons DataFrame vs Series inconsistency · Issue #28079 · pandas-dev/pandas (original) (raw)
In tests.frame.test_arithmetic we test the DataFrame part of the following, but we do not test the Series behavior (at least not in that file)
arr = np.array([np.nan, 1, 6, np.nan])
arr2 = np.array([2j, np.nan, 7, None])
ser = pd.Series(arr)
ser2 = pd.Series(arr2)
df = pd.DataFrame(ser)
df2 = pd.DataFrame(ser2)
ser < ser2 # raises TypeError, makes sense
df < df2 # raises TypeError, makes sense
ser.lt(ser2) # raises TypeError, makes sense
>>> df.lt(df2)
0
0 False
1 False
2 True
3 False
The df.lt(df2)
version (the "flex" op) masks positions where either df
or df2
is null. That is fine, but why doesn't the Series
version do the same thing?