A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/pandas-dev/pandas/issues/8979 below:

groupby().nth() missing docs, throws errors when multiple columns in group · Issue #8979 · pandas-dev/pandas · GitHub

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

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4