Skip to content

Commit dcaa5c2

Browse files
authoredNov 9, 2020
CLN: clean categorical indexes tests (#37721)
1 parent 75eb0cf commit dcaa5c2

File tree

1 file changed

+2
-23
lines changed

1 file changed

+2
-23
lines changed
 

‎pandas/tests/indexing/test_categorical.py

+2-23
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,6 @@ def test_loc_scalar(self):
5959
with pytest.raises(TypeError, match=msg):
6060
df.loc["d"] = 10
6161

62-
msg = (
63-
"cannot insert an item into a CategoricalIndex that is not "
64-
"already an existing category"
65-
)
6662
msg = "'fill_value=d' is not present in this Categorical's categories"
6763
with pytest.raises(ValueError, match=msg):
6864
df.loc["d", "A"] = 10
@@ -74,9 +70,9 @@ def test_loc_scalar(self):
7470

7571
def test_slicing(self):
7672
cat = Series(Categorical([1, 2, 3, 4]))
77-
reversed = cat[::-1]
73+
reverse = cat[::-1]
7874
exp = np.array([4, 3, 2, 1], dtype=np.int64)
79-
tm.assert_numpy_array_equal(reversed.__array__(), exp)
75+
tm.assert_numpy_array_equal(reverse.__array__(), exp)
8076

8177
df = DataFrame({"value": (np.arange(100) + 1).astype("int64")})
8278
df["D"] = pd.cut(df.value, bins=[0, 25, 50, 75, 100])
@@ -170,23 +166,6 @@ def test_slicing_and_getting_ops(self):
170166
res_val = df.loc["j", "cats"]
171167
assert res_val == exp_val
172168

173-
# ix
174-
# frame
175-
# res_df = df.loc["j":"k",[0,1]] # doesn't work?
176-
res_df = df.loc["j":"k", :]
177-
tm.assert_frame_equal(res_df, exp_df)
178-
assert is_categorical_dtype(res_df["cats"].dtype)
179-
180-
# row
181-
res_row = df.loc["j", :]
182-
tm.assert_series_equal(res_row, exp_row)
183-
assert isinstance(res_row["cats"], str)
184-
185-
# col
186-
res_col = df.loc[:, "cats"]
187-
tm.assert_series_equal(res_col, exp_col)
188-
assert is_categorical_dtype(res_col.dtype)
189-
190169
# single value
191170
res_val = df.loc["j", df.columns[0]]
192171
assert res_val == exp_val

0 commit comments

Comments
 (0)
Please sign in to comment.