Skip to content

Commit c2293be

Browse files
another-greenjreback
authored andcommitted
TST: Add test for operations on DataFrame with Interval CategoricalIndex (#27443)
1 parent a39bcb5 commit c2293be

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

pandas/tests/frame/test_arithmetic.py

+11
Original file line numberDiff line numberDiff line change
@@ -642,3 +642,14 @@ def test_arith_non_pandas_object(self):
642642
val3 = np.random.rand(*df.shape)
643643
added = pd.DataFrame(df.values + val3, index=df.index, columns=df.columns)
644644
tm.assert_frame_equal(df.add(val3), added)
645+
646+
def test_operations_with_interval_categories_index(self, all_arithmetic_operators):
647+
# GH#27415
648+
op = all_arithmetic_operators
649+
ind = pd.CategoricalIndex(pd.interval_range(start=0.0, end=2.0))
650+
data = [1, 2]
651+
df = pd.DataFrame([data], columns=ind)
652+
num = 10
653+
result = getattr(df, op)(num)
654+
expected = pd.DataFrame([[getattr(n, op)(num) for n in data]], columns=ind)
655+
tm.assert_frame_equal(result, expected)

0 commit comments

Comments
 (0)