Skip to content

nth groupby method on DataFrame #5552

Closed
@hayd

Description

@hayd

The nth groupby method on a Series takes the nth non-NaN value in the Series.

This means on a DataFrame it's not going to be well defined...

Should we make this a Series only method?

In [1]: g = pd.DataFrame([['a'], ['a'], ['a'], ['b'], ['b'], ['a']],columns=['A']).groupby('A')

In [2]: g.nth(0)
Out[2]: 
Empty DataFrame
Columns: []
Index: []

In [3]: g.A.nth(0)
Out[3]: 
A
a    a
b    b
Name: A, dtype: object

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions