Skip to content

Commit 0fb892d

Browse files
TST: pd.concat on two (or more) series produces all-NaN dataframe (#33728)
1 parent 652a39f commit 0fb892d

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

pandas/tests/reshape/test_concat.py

+34
Original file line numberDiff line numberDiff line change
@@ -2768,3 +2768,37 @@ def test_concat_copy_index(test_series, axis):
27682768
comb = concat([df, df], axis=axis, copy=True)
27692769
assert comb.index is not df.index
27702770
assert comb.columns is not df.columns
2771+
2772+
2773+
def test_concat_multiindex_datetime_object_index():
2774+
# https://github.com/pandas-dev/pandas/issues/11058
2775+
s = Series(
2776+
["a", "b"],
2777+
index=MultiIndex.from_arrays(
2778+
[[1, 2], Index([dt.date(2013, 1, 1), dt.date(2014, 1, 1)], dtype="object")],
2779+
names=["first", "second"],
2780+
),
2781+
)
2782+
s2 = Series(
2783+
["a", "b"],
2784+
index=MultiIndex.from_arrays(
2785+
[[1, 2], Index([dt.date(2013, 1, 1), dt.date(2015, 1, 1)], dtype="object")],
2786+
names=["first", "second"],
2787+
),
2788+
)
2789+
expected = DataFrame(
2790+
[["a", "a"], ["b", np.nan], [np.nan, "b"]],
2791+
index=MultiIndex.from_arrays(
2792+
[
2793+
[1, 2, 2],
2794+
DatetimeIndex(
2795+
["2013-01-01", "2014-01-01", "2015-01-01"],
2796+
dtype="datetime64[ns]",
2797+
freq=None,
2798+
),
2799+
],
2800+
names=["first", "second"],
2801+
),
2802+
)
2803+
result = concat([s, s2], axis=1)
2804+
tm.assert_frame_equal(result, expected)

0 commit comments

Comments
 (0)