-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
ENH: Add na_value argument to DataFrame.to_numpy #33857
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 25 commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
054d74e
ENH: Add na_value argument to DataFrame.to_numpy
dsaxton cafbf5f
Add some tests
dsaxton 34b9b9f
Issue num
dsaxton 9a2bbd6
A little better
dsaxton f7dc246
Merge remote-tracking branch 'upstream/master' into dataframe-to-numpy
dsaxton 5eb8bb2
as_array
dsaxton ec2f729
Merge remote-tracking branch 'upstream/master' into dataframe-to-numpy
dsaxton b48b6c9
Black
dsaxton d1a60e8
More black
dsaxton 09fdf51
to_numpy for ExtensionBlock
dsaxton f5db15a
Merge remote-tracking branch 'upstream/master' into dataframe-to-numpy
dsaxton 89e8930
dtype hack
dsaxton d24b976
Merge remote-tracking branch 'upstream/master' into dataframe-to-numpy
dsaxton bec3889
reshape
dsaxton a20f116
Merge remote-tracking branch 'upstream/master' into dataframe-to-numpy
dsaxton 02405a1
Check for NA first
dsaxton 055413f
Cast non-extension single block
dsaxton ae088e4
Test nit
dsaxton d78ba29
Update pandas/core/frame.py
dsaxton 9c87e00
side effect test
dsaxton df5b683
Merge remote-tracking branch 'upstream/master' into dataframe-to-numpy
dsaxton ae2b34a
Update pandas/tests/base/test_conversion.py
dsaxton bcb69c5
Copy
dsaxton c3a7a55
Copy less
dsaxton b5ec43f
Merge remote-tracking branch 'upstream/master' into dataframe-to-numpy
dsaxton f3e45d7
should_copy
dsaxton e54cc28
Merge remote-tracking branch 'upstream/master' into dataframe-to-numpy
dsaxton 491a5ae
Update pandas/core/internals/managers.py
dsaxton 4ecccff
Rename and comment
dsaxton 142c808
Merge remote-tracking branch 'upstream/master' into dataframe-to-numpy
dsaxton 8d42fd4
Don't special case datetimetz
dsaxton c2228bf
Merge remote-tracking branch 'upstream/master' into dataframe-to-numpy
dsaxton 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
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 |
---|---|---|
|
@@ -365,7 +365,7 @@ def test_to_numpy_copy(self): | |
df = pd.DataFrame(arr) | ||
assert df.values.base is arr | ||
assert df.to_numpy(copy=False).base is arr | ||
assert df.to_numpy(copy=True).base is None | ||
assert df.to_numpy(copy=True).base is not arr | ||
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. This had to change because now the output array is a view, but only on the transpose of itself (which is a copy of the original data) |
||
|
||
def test_swapaxes(self): | ||
df = DataFrame(np.random.randn(10, 5)) | ||
|
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you might be able to remove the block aboev (is_datetimetz) as that is an extension block already
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, the
DatetimeArray.to_numpy
behaviour seems correct for the default (having object dtype with timestamps instead of datetime64)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice 👍