Skip to content

Commit

Permalink
TST:Add test to check single category col returns series with single …
Browse files Browse the repository at this point in the history
…row slice (pandas-dev#29521)

Closes pandas-dev#14011
  • Loading branch information
ryankarlos authored and proost committed Dec 19, 2019
1 parent a7fb364 commit c470359
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions pandas/tests/frame/test_dtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -762,6 +762,15 @@ def test_astype_categoricaldtype_class_raises(self, cls):
with pytest.raises(TypeError, match=xpr):
df["A"].astype(cls)

def test_singlerow_slice_categoricaldtype_gives_series(self):
# GH29521
df = pd.DataFrame({"x": pd.Categorical("a b c d e".split())})
result = df.iloc[0]
raw_cat = pd.Categorical(["a"], categories=["a", "b", "c", "d", "e"])
expected = pd.Series(raw_cat, index=["x"], name=0, dtype="category")

tm.assert_series_equal(result, expected)

@pytest.mark.parametrize("dtype", ["Int64", "Int32", "Int16"])
def test_astype_extension_dtypes(self, dtype):
# GH 22578
Expand Down

0 comments on commit c470359

Please sign in to comment.