Skip to content

Can't combine DatetimeIndex MultiIndex with numeric MultiIndex #42143

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Dec 19, 2021
30 changes: 30 additions & 0 deletions pandas/tests/reshape/concat/test_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,3 +265,33 @@ def test_concat_multiindex_dfs_with_deepcopy(self):
tm.assert_frame_equal(result_copy, expected)
result_no_copy = concat(example_dict, names=["testname"])
tm.assert_frame_equal(result_no_copy, expected)

@pytest.mark.parametrize(
"mi1",
[
MultiIndex.from_product([["a"], range(2)]),
MultiIndex.from_product([["a"], np.arange(2.0)]),
MultiIndex.from_product([["b"], ["A", "B"]]),
MultiIndex.from_product(
[["c"], pd.date_range(start="2017", end="2018", periods=2)]
),
],
)
@pytest.mark.parametrize(
"mi2",
[
MultiIndex.from_product([["a"], range(2)]),
MultiIndex.from_product([["a"], np.arange(2.0)]),
MultiIndex.from_product([["b"], ["A", "B"]]),
MultiIndex.from_product(
[["c"], pd.date_range(start="2017", end="2018", periods=2)]
),
],
)
def test_concat_with_various_multiindex_dtypes(self, mi1, mi2):
# GitHub #23478
df1 = DataFrame(np.zeros((1, len(mi1))), columns=mi1)
df2 = DataFrame(np.zeros((1, len(mi2))), columns=mi2)

with tm.assert_produces_warning(None):
concat((df1, df2), axis=1)