-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
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
REGR: fix bug in DatetimeIndex slicing with irregular or unsorted indices #37023
Merged
jreback
merged 24 commits into
pandas-dev:master
from
CloseChoice:BUG-regression-datetimeindex-slicing
Oct 26, 2020
Merged
Changes from 7 commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
f1d4a10
remove assert in core/generic.py and add test for datetimeindex slicing
CloseChoice cd1a136
fix formatting in test_generic
CloseChoice fe478c4
fix test and remove commented line
CloseChoice 15a9185
updated tests according to PR comments
CloseChoice 6caba47
slice with loc to prevent future warning
CloseChoice 5703994
revert changes in io/formats/css.py
CloseChoice 4a7ff03
run black on test_timeseries.py
CloseChoice 25b229c
move tests to indexing/test_partial, add whatsnew entry
CloseChoice 9bb10fe
reformat test_timeseries.py
CloseChoice 9d82f83
Merge branch 'master' of https://github.com/pandas-dev/pandas into BU…
CloseChoice 968fdf4
update whatsnew
CloseChoice 89b0248
Merge branch 'master' into BUG-regression-datetimeindex-slicing
CloseChoice 3710514
add suggestion from comment
CloseChoice 237b085
use result and expected in tests
CloseChoice 43a2a26
Merge branch 'master' of https://github.com/pandas-dev/pandas into BU…
CloseChoice 632855b
Update doc/source/whatsnew/v1.1.4.rst
CloseChoice e79cdac
Merge branch 'master' of https://github.com/pandas-dev/pandas into BU…
CloseChoice e5f3615
Merge branch 'BUG-regression-datetimeindex-slicing' of github.com:Clo…
CloseChoice 4261f02
Merge branch 'master' of https://github.com/pandas-dev/pandas into BU…
CloseChoice 583003e
Merge remote-tracking branch 'upstream/master' into BUG-regression-da…
simonjayhawkins e246520
Update pandas/tests/indexing/test_partial.py
MarcoGorelli 9cf919e
Update pandas/tests/indexing/test_partial.py
MarcoGorelli 7f693dc
Update pandas/tests/indexing/test_partial.py
MarcoGorelli 02ae223
Update pandas/tests/indexing/test_partial.py
MarcoGorelli 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 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 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 |
---|---|---|
|
@@ -63,3 +63,22 @@ def test_datetime_assignment_with_NaT_and_diff_time_units(self): | |
{0: [1, None], "new": [1e9, None]}, dtype="datetime64[ns]" | ||
) | ||
tm.assert_frame_equal(result, expected) | ||
|
||
def test_slice_irregular_datetime_index_with_nan(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. move these to pandas/tests/indexing/test_partial.py always use |
||
# GH36953 | ||
index = pd.to_datetime(["2012-01-01", "2012-01-02", "2012-01-03", None]) | ||
df = pd.DataFrame(range(len(index)), index=index) | ||
expected = pd.DataFrame(range(len(index[:3])), index=index[:3]) | ||
tm.assert_frame_equal(df["2012-01-01":"2012-01-04"], expected) | ||
|
||
def test_slice_datetime_index(self): | ||
# GH35509 | ||
df = pd.DataFrame( | ||
{"col1": ["a", "b", "c"], "col2": [1, 2, 3]}, | ||
index=pd.to_datetime(["2020-08-01", "2020-07-02", "2020-08-05"]), | ||
) | ||
expected = pd.DataFrame( | ||
{"col1": ["a", "c"], "col2": [1, 3]}, | ||
index=pd.to_datetime(["2020-08-01", "2020-08-05"]), | ||
) | ||
tm.assert_frame_equal(df.loc["2020-08"], expected) |
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.
this is not the patch; something is going down the wrong path and ending up here. this routine is only for slices.
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.
Ok, I will look into that. I just wanted to note that in version 1.0.9 it went down just the same path except that the exception wasn't there yet. In this sense we are not talking about a regression but about fixing a bug which seems to have been there since a while ago.
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.
@CloseChoice can you check if the suggestion from here #35509 (comment) passes the tests you added?