-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
PERF: use non-copying path for Groupby.skew #52104
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
Changes from all commits
f909a2d
293b9c0
5823f8b
ea4d54c
f94a1b3
baafbaa
4ca8bed
1f1a268
294a500
9333c78
3069f4c
bc0b67a
04acbf5
c34cdad
7e84d04
78096ed
67d2669
9609c95
703f2aa
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import numpy as np | ||
|
||
import pandas as pd | ||
import pandas._testing as tm | ||
|
||
|
||
def test_groupby_skew_equivalence(): | ||
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. Do we do this for the other functions? I like the idea; seems like it would be good to consolidate this with others in a follow up 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. groupby tests are not super well-organized, would be nice to improve someday |
||
# Test that that groupby skew method (which uses libgroupby.group_skew) | ||
# matches the results of operating group-by-group (which uses nanops.nanskew) | ||
nrows = 1000 | ||
ngroups = 3 | ||
ncols = 2 | ||
nan_frac = 0.05 | ||
|
||
arr = np.random.randn(nrows, ncols) | ||
arr[np.random.random(nrows) < nan_frac] = np.nan | ||
|
||
df = pd.DataFrame(arr) | ||
grps = np.random.randint(0, ngroups, size=nrows) | ||
gb = df.groupby(grps) | ||
|
||
result = gb.skew() | ||
|
||
grpwise = [grp.skew().to_frame(i).T for i, grp in gb] | ||
expected = pd.concat(grpwise, axis=0) | ||
expected.index = expected.index.astype(result.index.dtype) # 32bit builds | ||
tm.assert_frame_equal(result, expected) |
Uh oh!
There was an error while loading. Please reload this page.