Skip to content

Commit f960208

Browse files
authored
GH31581 adding regression test (#52740)
1 parent 7059b7b commit f960208

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

pandas/tests/frame/indexing/test_setitem.py

+11
Original file line numberDiff line numberDiff line change
@@ -1263,6 +1263,17 @@ def test_setitem_column_update_inplace(self, using_copy_on_write):
12631263
# original dataframe not updated
12641264
assert np.all(values[np.arange(10), np.arange(10)] == 0)
12651265

1266+
def test_setitem_column_frame_as_category(self):
1267+
# GH31581
1268+
df = DataFrame([1, 2, 3])
1269+
df["col1"] = DataFrame([1, 2, 3], dtype="category")
1270+
df["col2"] = Series([1, 2, 3], dtype="category")
1271+
1272+
expected_types = Series(
1273+
["int64", "category", "category"], index=[0, "col1", "col2"]
1274+
)
1275+
tm.assert_series_equal(df.dtypes, expected_types)
1276+
12661277
@pytest.mark.parametrize("dtype", ["int64", "Int64"])
12671278
def test_setitem_iloc_with_numpy_array(self, dtype):
12681279
# GH-33828

0 commit comments

Comments
 (0)