BUG: casting on concat with empties (#38907) · pandas-dev/pandas@04282c7 (original) (raw)

Original file line number Diff line number Diff line change
@@ -82,6 +82,7 @@ def test_append_length0_frame(self, sort):
82 82 df5 = df.append(df3, sort=sort)
83 83
84 84 expected = DataFrame(index=[0, 1], columns=["A", "B", "C"])
85 +expected["C"] = expected["C"].astype(np.float64)
85 86 tm.assert_frame_equal(df5, expected)
86 87
87 88 def test_append_records(self):
@@ -340,16 +341,11 @@ def test_append_empty_frame_to_series_with_dateutil_tz(self):
340 341 expected = DataFrame(
341 342 [[np.nan, np.nan, 1.0, 2.0, date]], columns=["c", "d", "a", "b", "date"]
342 343 )
343 -# These columns get cast to object after append
344 -expected["c"] = expected["c"].astype(object)
345 -expected["d"] = expected["d"].astype(object)
346 344 tm.assert_frame_equal(result_a, expected)
347 345
348 346 expected = DataFrame(
349 347 [[np.nan, np.nan, 1.0, 2.0, date]] * 2, columns=["c", "d", "a", "b", "date"]
350 348 )
351 -expected["c"] = expected["c"].astype(object)
352 -expected["d"] = expected["d"].astype(object)
353 349
354 350 result_b = result_a.append(s, ignore_index=True)
355 351 tm.assert_frame_equal(result_b, expected)