Skip to content

Consolidate nth / last object Groupby Implementations #19610

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 2 commits into from
Feb 10, 2018

Conversation

WillAyd
Copy link
Member

@WillAyd WillAyd commented Feb 9, 2018

Depending on what goes first between this and #19481 some merge conflicts will need to be cleaned up

@@ -360,11 +361,19 @@ def group_last_{{name}}(ndarray[{{dest_type2}}, ndim=2] out,
raise AssertionError("len(index) != len(labels)")

nobs = np.zeros((<object> out).shape, dtype=np.int64)
{{if name=='object'}}
resx = np.empty((<object> out).shape, dtype=object)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was really hoping to not even have this conditional, but when trying resx = np.empty_like(out) and even resx = np.empty_like(out, dtype='object') it kept SegFaulting on objects

@codecov
Copy link

codecov bot commented Feb 9, 2018

Codecov Report

Merging #19610 into master will decrease coverage by 0.02%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #19610      +/-   ##
==========================================
- Coverage   91.62%   91.59%   -0.03%     
==========================================
  Files         150      150              
  Lines       48790    48790              
==========================================
- Hits        44703    44691      -12     
- Misses       4087     4099      +12
Flag Coverage Δ
#multiple 89.97% <ø> (-0.03%) ⬇️
#single 41.73% <ø> (ø) ⬆️
Impacted Files Coverage Δ
pandas/plotting/_converter.py 65.22% <0%> (-1.74%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b835127...fa63b47. Read the comment docs.

('last', [('bar', 'grault'), ('foo', 'quux')], []),
('nth', [('bar', 'corge'), ('foo', 'qux')], [1]),
])
def test_groupby_get_nth_object(self, method, exp, args):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think the nth tests are in another test file

@jreback jreback added this to the 0.23.0 milestone Feb 9, 2018
Copy link
Contributor

@jreback jreback left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm. going to merge the other PR first.

@@ -2086,47 +2086,45 @@ def test_median_empty_bins(self):
expected = df.groupby(bins).agg(lambda x: x.median())
assert_frame_equal(result, expected)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add a tests with the numeric ops on groupby / object and assert they raise

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assuming you want this in a different change no problem. That said, do you consider the numeric ops to be add, prod, min, max, mean, median, var, ohlc, cumprod, cumsum, cummin, cummax and rank? The tests are one thing, but these don't all raise at the moment so would have to couple that with some refactoring of the groupby module

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes let's do this in another change.

@jreback jreback merged commit d4730e6 into pandas-dev:master Feb 10, 2018
@jreback
Copy link
Contributor

jreback commented Feb 10, 2018

thanks!

jreback added a commit that referenced this pull request Feb 10, 2018
@jreback
Copy link
Contributor

jreback commented Feb 10, 2018

@WillAyd I merged this, then reverted it. Can you send a new PR that is rebased on master?

@jreback
Copy link
Contributor

jreback commented Feb 10, 2018

Reverted in 5c76f33

harisbal pushed a commit to harisbal/pandas that referenced this pull request Feb 28, 2018
harisbal pushed a commit to harisbal/pandas that referenced this pull request Feb 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CLN: consolidate last / nth object dtype groupby function implementation
2 participants