-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: Series.asof fails for all NaN Series (GH15713) #15758
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
Closed
Closed
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
676a4e5
Test
c78d687
BUG #15713 Series.asof return nan when series is all nans
4e26ab8
BUG #15713 Series.asof return nan when series is all nans.
17d1d77
BUG #15713 Series.asof return nan when series is all nans!
89fb6cf
BUG #15713 fixing failing tests
6b745af
Adding DataFrame tests & support, and optimizing the code
70c958f
Added tests for non-default indexes, scalar and multiple inputs, and …
3f9c7fd
Minor comments
04b7306
Removing .values and formating code PEP8
a080b9b
Making scalar input return in a Series
7448b96
Fixing scalar input
b8f078a
Small code standard change
af9a29b
Setting name of asof result when scalar input and all nan
bb63964
Propagating Series name
0765108
First simplification, code-block in the same place
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 |
---|---|---|
|
@@ -148,3 +148,28 @@ def test_errors(self): | |
s = Series(np.random.randn(N), index=rng) | ||
with self.assertRaises(ValueError): | ||
s.asof(s.index[0], subset='foo') | ||
|
||
def test_all_nans(self): | ||
# GH 15713 | ||
# series is all nans | ||
result = Series([np.nan]).asof([0]) | ||
expected = Series([np.nan]) | ||
tm.assert_series_equal(result, expected) | ||
|
||
# testing non-default indexes | ||
N = 50 | ||
rng = date_range('1/1/1990', periods=N, freq='53s') | ||
|
||
dates = date_range('1/1/1990', periods=N * 3, freq='25s') | ||
result = Series(np.nan, index=rng).asof(dates) | ||
expected = Series(np.nan, index=dates) | ||
tm.assert_series_equal(result, expected) | ||
|
||
# testing scalar input | ||
date = date_range('1/1/1990', periods=N * 3, freq='25s')[0] | ||
result = Series(np.nan, index=rng).asof(date) | ||
assert isnull(result) | ||
|
||
# test name is propagated | ||
result = Series(np.nan, index=[1, 2, 3, 4], name='test').asof([4, 5]) | ||
self.assertEqual(result.name, 'test') | ||
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 needs a 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. but I'll do on merge |
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.
FYI in the future, if you put the whatnew notes in a blank space in Bug Fixes (these are on purpose), you wont' get merge conflicts