-
-
Notifications
You must be signed in to change notification settings - Fork 18.6k
BUG: Fix from_records() column reorder issue, if columns!=None use passed param (#59717) #59809
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
mroeschke
merged 14 commits into
pandas-dev:main
from
VibavariG:59717-from-records-columns-reorder
Sep 25, 2024
Merged
Changes from 11 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
b5a6648
BUG: Fix columns param reorder issue - if columns!=None, use passed p…
500bb6f
Add tests for to_arrays()
9420549
Fix import order with isort
1bf53f2
fix sort
7a054fb
Update datatype to int32
4b47b39
Fis test
b9e7af2
Revert commit
a3d353f
Merge remote-tracking branch 'upstream/main' into 59717-from-records-…
35261c0
Add test for DaaFrame.from_records()
566ca76
Apply comments
7c82e5b
Merge remote-tracking branch 'upstream/main' into 59717-from-records-…
0ccc362
Merge remote-tracking branch 'upstream/main' into 59717-from-records-…
3eddd98
Delete test_to_arrays.py
f9d6b8c
Merge remote-tracking branch 'upstream/main' into 59717-from-records-…
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
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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import numpy as np | ||
from numpy import array | ||
|
||
import pandas._testing as tm | ||
from pandas.core.indexes.api import ensure_index | ||
from pandas.core.internals.construction import to_arrays | ||
|
||
|
||
def test_to_arrays(): | ||
# GH 59717 | ||
data = np.array( | ||
[ | ||
("John", 25, "New York", 50000), | ||
("Jane", 30, "San Francisco", 75000), | ||
("Bob", 35, "Chicago", 65000), | ||
("Alice", 28, "Los Angeles", 60000), | ||
], | ||
dtype=[("name", "U10"), ("age", "i4"), ("city", "U15"), ("salary", "i4")], | ||
) | ||
|
||
columns = ["name", "salary", "city"] | ||
indexed_columns = ensure_index(columns) | ||
|
||
actual_arrays, actual_cols = to_arrays(data, indexed_columns) | ||
VibavariG marked this conversation as resolved.
Show resolved
Hide resolved
|
||
expected_arrays = [ | ||
array(["John", "Jane", "Bob", "Alice"], dtype="<U10"), | ||
array([50000, 75000, 65000, 60000], dtype="int32"), | ||
array(["New York", "San Francisco", "Chicago", "Los Angeles"], dtype="<U15"), | ||
] | ||
|
||
for actual, expected in zip(actual_arrays, expected_arrays): | ||
tm.assert_numpy_array_equal(actual, expected) | ||
|
||
assert actual_cols.equals(indexed_columns) |
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.