pydata/pandas — pull request #7044 by jreback (2014-05-05 12:43:30+00:00)
Title: API: update nth to use the _set_selection_from_grouper makes first==nth(0) and last==nth(-1)

closes #6732

``nth`` sets the index appropriately and the same as first/last.

this becomes less like head/tail in that ``as_index`` determines when you have an index

here's the revised behavior:

```
In [1]: df = DataFrame([[1, np.nan], [1, 4], [5, 6]], columns=['A', 'B'])

In [3]: df
Out[3]:
A B
0 1 NaN
1 1 4
2 5 6

[3 rows x 2 columns]

In [2]: g = df.groupby('A')

In [9]: gni = df.groupby('A',as_index=False)
```

```
In [5]: g.first()
Out[5]:
B
A
1 4
5 6

[2 rows x 1 columns]

# this was a regression from 0.13.1 (in that before this PR, this was returning like ``as_index=False``)
In [6]: g.nth(0)
Out[6]:
B
A
1 NaN
5 6

[2 rows x 1 columns]

In [7]: g.nth(0,dropna='all')
Out[7]:
B
A
1 4
5 6

[2 rows x 1 columns]
```

```
In [10]: gni.nth(0)
Out[10]:
A B
0 1 NaN
2 5 6

[2 rows x 2 columns]

In [11]: gni.nth(0,dropna='all')
Out[11]:
A B
0 1 4
1 5 6

[2 rows x 2 columns]
```