groupby().nth() missing docs, throws errors when multiple columns in group · Issue #8979 · pandas-dev/pandas (original) (raw)
Hi All!
I've been using .nth(), and found a couple issues (though it's extremely useful in general!). In particular, I couldn't find any help documentation (in python) for the function.
Also, I ran into issues with I had a two-column groupby. for example:
df = pd.DataFrame([[1,2,3],[1,5,6], [7,8,6]], columns = ['col1','col2','col3'])
df.groupby('col1').nth([0,1])
Is ok
In [23]: df.groupby(['col1', 'col2'], as_index = False).nth([0,1])
Out[23]:
col1 col2 col3
0 1 2 3
1 1 5 6
2 7 8 6
In [24]: df.groupby(['col1', 'col2']).nth([0,1])
ValueError: Length of new names must be 1, got 2