-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Bug fix using GroupBy.resample produces inconsistent behavior when calling it over empty df #47705 #47672
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 fix using GroupBy.resample produces inconsistent behavior when calling it over empty df #47705 #47672
Changes from all commits
Commits
Show all changes
53 commits
Select commit
Hold shift + click to select a range
54c5068
DOC #45443 edited the documentation of where/mask functions
ahmedibrhm 2951fb1
DOC #45443 edited the documentation of where/mask functions
ahmedibrhm 6335204
Merge branch 'main' into main
ahmedibrhm 8afd6a1
Update generic.py
ahmedibrhm 4d43e69
Bug 43767 fix
ahmedibrhm 75fdb73
fixing lines doc
ahmedibrhm 26dc5e8
visual indent
ahmedibrhm 47bcbb3
visual indent
ahmedibrhm 390ff5a
indentation
ahmedibrhm e8e51c4
grouby.resample bug
ahmedibrhm f25b760
Merge branch 'main' into issue4
ahmedibrhm d05f473
groubby.sample
ahmedibrhm 9c1fc4f
syntax
ahmedibrhm c671764
syntax
ahmedibrhm cdb642b
syntax
ahmedibrhm 891bc7c
syntax
ahmedibrhm 34dcf22
what's new
ahmedibrhm 2a51ddf
flake8 error
ahmedibrhm 1fe7026
pytest
ahmedibrhm 470dbb9
Merge branch 'main' into issue4
ahmedibrhm 9d48bfc
blank line
ahmedibrhm 2695f58
Merge branch 'issue4' of https://github.com/ahmedibrhm/pandas into is…
ahmedibrhm a076f44
editting resample
ahmedibrhm 163e287
Merge branch 'main' into issue4
ahmedibrhm 1450abd
editting resample
ahmedibrhm 2cde833
Merge branch 'issue4' of https://github.com/ahmedibrhm/pandas into is…
ahmedibrhm 0a45b1f
syntax
ahmedibrhm c04db0e
syntax
ahmedibrhm a47ba76
Merge branch 'main' into issue4
ahmedibrhm 3a9070d
syntax
ahmedibrhm 73cfe7c
Merge branch 'issue4' of https://github.com/ahmedibrhm/pandas into is…
ahmedibrhm e683177
space
ahmedibrhm b10a311
space
ahmedibrhm d3af97b
space
ahmedibrhm 41c44ce
Merge branch 'main' into issue4
ahmedibrhm 23d37ce
inplace
ahmedibrhm 53d6649
Merge branch 'issue4' of https://github.com/ahmedibrhm/pandas into is…
ahmedibrhm 42f141b
spelling
ahmedibrhm b54483b
test
ahmedibrhm 819c836
Merge branch 'main' into issue4
ahmedibrhm 5e12d91
test resampler
ahmedibrhm 2f462ab
tests
ahmedibrhm 727a1c7
tests
ahmedibrhm b24b531
Merge branch 'main' into issue4
ahmedibrhm 988f37c
Merge branch 'main' into issue4
ahmedibrhm abee447
Merge branch 'main' into issue4
ahmedibrhm 0b01594
Update resample.py
ahmedibrhm 25e7cfd
Update resample.py
ahmedibrhm 900933b
Update resample.py
ahmedibrhm 77834b1
Merge branch 'main' into issue4
ahmedibrhm c178d4d
Update v1.6.0.rst
ahmedibrhm 0f05527
Merge branch 'main' into issue4
ahmedibrhm 308ed31
Merge branch 'main' into issue4
ahmedibrhm 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 |
---|---|---|
|
@@ -435,7 +435,11 @@ def test_empty(keys): | |
# GH 26411 | ||
df = DataFrame([], columns=["a", "b"], index=TimedeltaIndex([])) | ||
result = df.groupby(keys).resample(rule=pd.to_timedelta("00:00:01")).mean() | ||
expected = DataFrame(columns=["a", "b"]).set_index(keys, drop=False) | ||
expected = ( | ||
DataFrame(columns=["a", "b"]) | ||
.set_index(keys, drop=False) | ||
.set_index(TimedeltaIndex([]), append=True) | ||
) | ||
if len(keys) == 1: | ||
expected.index.name = keys[0] | ||
|
||
|
@@ -497,3 +501,19 @@ def test_groupby_resample_with_list_of_keys(): | |
), | ||
) | ||
tm.assert_frame_equal(result, expected) | ||
|
||
|
||
@pytest.mark.parametrize("keys", [["a"], ["a", "b"]]) | ||
def test_resample_empty_Dataframe(keys): | ||
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. Is it possible to combine this with |
||
# GH 47705 | ||
df = DataFrame([], columns=["a", "b", "date"]) | ||
df["date"] = pd.to_datetime(df["date"]) | ||
df = df.set_index("date") | ||
result = df.groupby(keys).resample(rule=pd.to_timedelta("00:00:01")).mean() | ||
expected = DataFrame(columns=["a", "b", "date"]).set_index(keys, drop=False) | ||
expected["date"] = pd.to_datetime(expected["date"]) | ||
expected = expected.set_index("date", append=True, drop=True) | ||
if len(keys) == 1: | ||
expected.index.name = keys[0] | ||
|
||
tm.assert_frame_equal(result, 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.
Could you add
# GH 47705
here?