-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
fix bug when combining groupby with resample and interpolate with dat… #35360
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
jreback
merged 10 commits into
pandas-dev:master
from
CloseChoice:fix_groupby_resample_interpolate
Aug 19, 2020
Merged
Changes from 2 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
00d53f8
fix bug when combining groupby with resample and interpolate with dat…
CloseChoice c35b3c6
Merge branch 'master' of https://github.com/pandas-dev/pandas into fi…
CloseChoice 9442fce
Merge branch 'master' into fix_groupby_resample_interpolate
CloseChoice c593a83
added whatsnew entry in v1.2.0
CloseChoice 556e6a3
Merge branch 'master' into fix_groupby_resample_interpolate
CloseChoice 87486b8
removed merge markers
CloseChoice 715f8a4
Merge branch 'master' of https://github.com/pandas-dev/pandas into fi…
CloseChoice a2070d9
Merge branch 'master' of https://github.com/pandas-dev/pandas into fi…
CloseChoice ef5bceb
moved test from test_resampler_grouper to test_time_grouper
CloseChoice 4e8385e
Merge branch 'master' of https://github.com/pandas-dev/pandas into fi…
CloseChoice 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 |
---|---|---|
|
@@ -346,3 +346,65 @@ def test_median_duplicate_columns(): | |
result = df.resample("5s").median() | ||
expected.columns = result.columns | ||
tm.assert_frame_equal(result, expected) | ||
|
||
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. can you move this to pandas/tests/resample/test_time_grouper.py |
||
|
||
def test_groupby_resample_interpolate(): | ||
# GH 35325 | ||
d = {"price": [10, 11, 9], "volume": [50, 60, 50]} | ||
|
||
df = pd.DataFrame(d) | ||
|
||
df["week_starting"] = pd.date_range("01/01/2018", periods=3, freq="W") | ||
|
||
result = ( | ||
df.set_index("week_starting") | ||
.groupby("volume") | ||
.resample("1D") | ||
.interpolate(method="linear") | ||
) | ||
expected_ind = pd.MultiIndex.from_tuples( | ||
[ | ||
(50, "2018-01-07"), | ||
(50, pd.Timestamp("2018-01-08")), | ||
(50, pd.Timestamp("2018-01-09")), | ||
(50, pd.Timestamp("2018-01-10")), | ||
(50, pd.Timestamp("2018-01-11")), | ||
(50, pd.Timestamp("2018-01-12")), | ||
(50, pd.Timestamp("2018-01-13")), | ||
(50, pd.Timestamp("2018-01-14")), | ||
(50, pd.Timestamp("2018-01-15")), | ||
(50, pd.Timestamp("2018-01-16")), | ||
(50, pd.Timestamp("2018-01-17")), | ||
(50, pd.Timestamp("2018-01-18")), | ||
(50, pd.Timestamp("2018-01-19")), | ||
(50, pd.Timestamp("2018-01-20")), | ||
(50, pd.Timestamp("2018-01-21")), | ||
(60, pd.Timestamp("2018-01-14")), | ||
], | ||
names=["volume", "week_starting"], | ||
) | ||
expected = pd.DataFrame( | ||
data={ | ||
"price": [ | ||
10.0, | ||
9.928571428571429, | ||
9.857142857142858, | ||
9.785714285714286, | ||
9.714285714285714, | ||
9.642857142857142, | ||
9.571428571428571, | ||
9.5, | ||
9.428571428571429, | ||
9.357142857142858, | ||
9.285714285714286, | ||
9.214285714285714, | ||
9.142857142857142, | ||
9.071428571428571, | ||
9.0, | ||
11.0, | ||
], | ||
"volume": [50.0] * 15 + [60], | ||
}, | ||
index=expected_ind, | ||
) | ||
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.
I might do
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.
Thanks for the link. I was looking for the whatsnew 1.2 but have seen that the PR, which will add this, is still open.
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.
has now been merged