Skip to content

Commit db99fb5

Browse files
jorisvandenbosscheadrien pacifico
authored andcommitted
Restore test_append_common.py to commit 6537afe
1 parent 109e3d0 commit db99fb5

File tree

1 file changed

+6
-14
lines changed

1 file changed

+6
-14
lines changed

pandas/tests/reshape/concat/test_append_common.py

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -486,17 +486,15 @@ def test_concat_categorical(self):
486486
s1 = Series([3, 2], dtype="category")
487487
s2 = Series([2, 1], dtype="category")
488488

489-
exp = Series([3, 2, 2, 1], dtype="category") # should remain category
489+
exp = Series([3, 2, 2, 1])
490490
tm.assert_series_equal(pd.concat([s1, s2], ignore_index=True), exp)
491491
tm.assert_series_equal(s1._append(s2, ignore_index=True), exp)
492492

493493
# completely different categories (same dtype) => not-category
494-
s1 = Series([10.0, 11.0, np.nan], dtype="category")
495-
s2 = Series([np.nan, 1.0, 3.0, 2.0], dtype="category")
494+
s1 = Series([10, 11, np.nan], dtype="category")
495+
s2 = Series([np.nan, 1, 3, 2], dtype="category")
496496

497-
exp = Series([10, 11, np.nan, np.nan, 1, 3, 2], dtype=np.float64).astype(
498-
"category"
499-
)
497+
exp = Series([10, 11, np.nan, np.nan, 1, 3, 2], dtype=np.float64)
500498
tm.assert_series_equal(pd.concat([s1, s2], ignore_index=True), exp)
501499
tm.assert_series_equal(s1._append(s2, ignore_index=True), exp)
502500

@@ -696,7 +694,7 @@ def test_concat_categorical_empty(self):
696694

697695
s1 = Series([], dtype="category")
698696
s2 = Series([1, 2], dtype="category")
699-
exp = s2
697+
exp = s2.astype(object)
700698
tm.assert_series_equal(pd.concat([s1, s2], ignore_index=True), exp)
701699
tm.assert_series_equal(s1._append(s2, ignore_index=True), exp)
702700

@@ -745,13 +743,7 @@ def test_categorical_concat_append(self):
745743
df_different_categories = DataFrame({"cats": cat3, "vals": vals3})
746744

747745
res = pd.concat([df, df_different_categories], ignore_index=True)
748-
exp = DataFrame(
749-
{
750-
"cats": Categorical(list("abab"), categories=["a", "b", "c"]),
751-
"vals": [1, 2, 1, 2],
752-
}
753-
) # I do not agree with the test made in #37243
754-
746+
exp = DataFrame({"cats": list("abab"), "vals": [1, 2, 1, 2]})
755747
tm.assert_frame_equal(res, exp)
756748

757749
res = df._append(df_different_categories, ignore_index=True)

0 commit comments

Comments
 (0)