-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
Bug cov nat #60898
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
Bug cov nat #60898
Changes from 10 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
bda0025
ENH: Add TypeError for unsupported datetime64 and timedelta64 dtypes …
fbourgey de954f7
TST: Add test for TypeError in DataFrame.cov with NaT and Timedelta i…
fbourgey 079adc7
Merge branch 'pandas-dev:main' into bug-cov-nat
fbourgey cff4f36
BUG: Improve error message for unsupported datetime and timedelta dty…
fbourgey df59a2c
BUG: Handle NaN values for datetime and timedelta dtypes in BlockManager
fbourgey dbceb26
BUG: Add test for to_numpy() handling of NaT and NaN values
fbourgey b1f64c8
Merge remote-tracking branch 'upstream/main' into bug-cov-nat
fbourgey cf53cc0
REF: Refactor imports in frame.py and update test imports in test_to_…
fbourgey 75d1f32
Merge remote-tracking branch 'upstream/main' into bug-cov-nat
fbourgey 5720684
update dtype check
fbourgey dafd24c
refactor
fbourgey c404086
Merge remote-tracking branch 'upstream/main' into bug-cov-nat
fbourgey ed4db14
update test
fbourgey 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 | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -3,7 +3,9 @@ | |||||||
|
||||||||
from pandas import ( | ||||||||
DataFrame, | ||||||||
NaT, | ||||||||
Timestamp, | ||||||||
date_range, | ||||||||
) | ||||||||
import pandas._testing as tm | ||||||||
|
||||||||
|
@@ -41,3 +43,37 @@ def test_to_numpy_mixed_dtype_to_str(self): | |||||||
result = df.to_numpy(dtype=str) | ||||||||
expected = np.array([["2020-01-01 00:00:00", "100.0"]], dtype=str) | ||||||||
tm.assert_numpy_array_equal(result, expected) | ||||||||
|
||||||||
def test_to_numpy_datetime_with_na(self): | ||||||||
# GH #53115 | ||||||||
dti = date_range("2016-01-01", periods=3) | ||||||||
df = DataFrame(dti) | ||||||||
df.iloc[0, 0] = NaT | ||||||||
expected = np.array([[np.nan], [1.45169280e18], [1.45177920e18]]) | ||||||||
assert np.allclose( | ||||||||
df.to_numpy(float, na_value=np.nan), expected, equal_nan=True | ||||||||
) | ||||||||
fbourgey marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||
|
||||||||
df = DataFrame( | ||||||||
{ | ||||||||
"a": [Timestamp("1970-01-01"), Timestamp("1970-01-02"), NaT], | ||||||||
"b": [ | ||||||||
Timestamp("1970-01-01"), | ||||||||
np.nan, | ||||||||
Timestamp("1970-01-02"), | ||||||||
], | ||||||||
"c": [ | ||||||||
1, | ||||||||
np.nan, | ||||||||
2, | ||||||||
], | ||||||||
} | ||||||||
) | ||||||||
arr = np.array( | ||||||||
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.
Suggested change
|
||||||||
[ | ||||||||
[0.00e00, 0.00e00, 1.00e00], | ||||||||
[8.64e04, np.nan, np.nan], | ||||||||
[np.nan, 8.64e04, 2.00e00], | ||||||||
] | ||||||||
) | ||||||||
assert np.allclose(df.to_numpy(float, na_value=np.nan), arr, equal_nan=True) | ||||||||
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.
Suggested change
|
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
Oops, something went wrong.
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.