Skip to content

TST: GH39984 Addition to tests #48042

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 6 commits into from
Aug 26, 2022
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions pandas/tests/indexes/multi/test_constructors.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@
import itertools

import numpy as np
import pyarrow as pa
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be imported in the test itself (its an optional dependency not installed on all builds)

import pytest

from pandas.compat import pa_version_under1p01

from pandas.core.dtypes.cast import construct_1d_object_array_from_listlike

import pandas as pd
Expand Down Expand Up @@ -647,6 +650,26 @@ def test_from_frame():
result = MultiIndex.from_frame(df)
tm.assert_index_equal(expected, result)


@pytest.mark.skipif(pa_version_under1p01)
def test_from_frame_missing_values_multiIndex():
# GH 39984
df = pd.DataFrame(
{
"a": Series([1, 2, None], dtype="Int64"),
"b": pd.Float64Dtype().__from_arrow__(pa.array([0.2, np.nan, None])),
}
)
multi_indexed = MultiIndex.from_frame(df)
expected = MultiIndex.from_arrays(
[
Series([1, 2, None]).astype("Int64"),
pd.Float64Dtype().__from_arrow__(pa.array([0.2, np.nan, None])),
],
names=["a", "b"],
)
tm.assert_index_equal(multi_indexed, expected)


@pytest.mark.parametrize(
"non_frame",
Expand Down