-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
BUG: DataFrame fail to construct when data is list and columns is nested list for MI #32202
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
Changes from 14 commits
Commits
Show all changes
44 commits
Select commit
Hold shift + click to select a range
7e461a1
remove \n from docstring
charlesdong1991 1314059
fix conflicts
charlesdong1991 8bcb313
Merge remote-tracking branch 'upstream/master'
charlesdong1991 24c3ede
Merge remote-tracking branch 'upstream/master'
charlesdong1991 dea38f2
fix issue 17038
charlesdong1991 cd9e7ac
revert change
charlesdong1991 e5e912b
revert change
charlesdong1991 e609188
Merge remote-tracking branch 'upstream/master' into fix_issue_32173
charlesdong1991 c8ee822
fix 32173
charlesdong1991 07ffde2
linting
charlesdong1991 b3f3da0
linting
charlesdong1991 2f2054c
add whatsnew
charlesdong1991 9176389
fix linting
charlesdong1991 ed02384
Merge remote-tracking branch 'upstream/master' into fix_issue_32173
charlesdong1991 d3b0c50
rebase and resolve conflict
charlesdong1991 a5e0d10
separate out column validation
charlesdong1991 6073ed7
code change based on JR review
charlesdong1991 e8f6d67
fixup
charlesdong1991 559b5d6
fixup
charlesdong1991 a452816
Merge remote-tracking branch 'upstream/master' into fix_issue_32173
charlesdong1991 3fd6743
rebase and fix conflict
charlesdong1991 2428edb
add docs and annotation
charlesdong1991 fe18e50
black
charlesdong1991 a5d159b
Add more docs
charlesdong1991 7516964
add annotation
charlesdong1991 86bd699
add for dict
charlesdong1991 30a70a7
remove unused import
charlesdong1991 a6cb139
Merge remote-tracking branch 'upstream/master' into fix_issue_32173
charlesdong1991 ed6dc4a
improve annotation
charlesdong1991 f058d2c
fix annotation
charlesdong1991 2852579
fix annotation
charlesdong1991 493ac33
fixup
charlesdong1991 3ecd6b8
more details
charlesdong1991 851a3e1
isort
charlesdong1991 9860985
better annotation
charlesdong1991 ffc6561
removed unused import
charlesdong1991 a028c33
linting
charlesdong1991 5af0f8e
code change on JB review
charlesdong1991 9eda16a
fixup
charlesdong1991 35e92ea
Merge remote-tracking branch 'upstream/master' into fix_issue_32173
charlesdong1991 44af738
fix conflicts
charlesdong1991 d0a10e4
Merge remote-tracking branch 'upstream/master' into fix_issue_32173
charlesdong1991 1700e5d
Merge remote-tracking branch 'upstream/master' into fix_issue_32173
charlesdong1991 8a036e4
Merge remote-tracking branch 'upstream/master' into fix_issue_32173
charlesdong1991 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1062,6 +1062,32 @@ def test_constructor_list_of_lists(self): | |
result = DataFrame(data) | ||
tm.assert_frame_equal(result, expected) | ||
|
||
def test_constructor_list_like_data_nested_list_column(self): | ||
# GH 32173 | ||
arrays = [list("abcd"), list("cdef")] | ||
result = pd.DataFrame([[1, 2, 3, 4], [4, 5, 6, 7]], columns=arrays) | ||
|
||
mi = MultiIndex.from_arrays(arrays) | ||
expected = pd.DataFrame([[1, 2, 3, 4], [4, 5, 6, 7]], columns=mi) | ||
|
||
tm.assert_frame_equal(result, expected) | ||
|
||
def test_constructor_wrong_length_nested_list_column(self): | ||
# GH 32173 | ||
arrays = [list("abc"), list("cde")] | ||
|
||
msg = "3 columns passed, passed data had 4" | ||
with pytest.raises(ValueError, match=msg): | ||
DataFrame([[1, 2, 3, 4], [4, 5, 6, 7]], columns=arrays) | ||
|
||
def test_constructor_inequal_length_nested_list_column(self): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. inequal -> unequal There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. corrected |
||
# GH 32173 | ||
arrays = [list("abcd"), list("cde")] | ||
|
||
msg = "Length of columns passed for MultiIndex columns is different" | ||
with pytest.raises(ValueError, match=msg): | ||
DataFrame([[1, 2, 3, 4], [4, 5, 6, 7]], columns=arrays) | ||
|
||
def test_constructor_sequence_like(self): | ||
# GH 3783 | ||
# collections.Squence like | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.