Skip to content

Add test for MultiIndex.from_tuples #52560

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 4 commits into from
Apr 10, 2023

Conversation

GrammatikakisDimitris
Copy link
Contributor


def test_multiindex_from_tuples_with_nan(self):
# GH#23578
multi_idx = MultiIndex.from_tuples([("a", "b", "c"), np.nan, ("d", "", "")])
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
multi_idx = MultiIndex.from_tuples([("a", "b", "c"), np.nan, ("d", "", "")])
result = MultiIndex.from_tuples([("a", "b", "c"), np.nan, ("d", "", "")])

def test_multiindex_from_tuples_with_nan(self):
# GH#23578
multi_idx = MultiIndex.from_tuples([("a", "b", "c"), np.nan, ("d", "", "")])
assert isinstance(multi_idx, MultiIndex)
Copy link
Member

Choose a reason for hiding this comment

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

Can you construct

expected = MultiIndex.from_tuples([("a", "b", "c"), (np.nan, np.nan, np.nan), ("d", "", "")])

and then call

tm.assert_index_equal_result, expected

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@mroeschke mroeschke added Testing pandas testing functions or related to the test suite MultiIndex labels Apr 10, 2023

def test_multiindex_from_tuples_with_nan(self):
# GH#23578
MultiIndex.from_tuples([("a", "b", "c"), np.nan, ("d", "", "")])
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
MultiIndex.from_tuples([("a", "b", "c"), np.nan, ("d", "", "")])
result = MultiIndex.from_tuples([("a", "b", "c"), np.nan, ("d", "", "")])

expected = MultiIndex.from_tuples(
[("a", "b", "c"), (np.nan, np.nan, np.nan), ("d", "", "")]
)
tm.assert_index_equal_result, expected
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
tm.assert_index_equal_result, expected
tm.assert_index_equal(result, expected)

@mroeschke mroeschke added this to the 2.1 milestone Apr 10, 2023
@mroeschke mroeschke merged commit 5b66502 into pandas-dev:main Apr 10, 2023
@mroeschke
Copy link
Member

Thanks @GrammatikakisDimitris

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
MultiIndex Testing pandas testing functions or related to the test suite
Projects
None yet
Development

Successfully merging this pull request may close these issues.

API/ERR/ENH: Allow MultiIndex.from_tuples to handle NaNs
2 participants