def test_first_last_nth_dtypes(self):
    df = self.df_mixed_floats.copy()
    df['E'] = True
    df['F'] = 1
    grouped = df.groupby('A')
    first = grouped.first()
    expected = df.loc[([1, 0], ['B', 'C', 'D', 'E', 'F'])]
    expected.index = Index(['bar', 'foo'], name='A')
    expected = expected.sort_index()
    assert_frame_equal(first, expected)
    last = grouped.last()
    expected = df.loc[([5, 7], ['B', 'C', 'D', 'E', 'F'])]
    expected.index = Index(['bar', 'foo'], name='A')
    expected = expected.sort_index()
    assert_frame_equal(last, expected)
    nth = grouped.nth(1)
    expected = df.loc[([3, 2], ['B', 'C', 'D', 'E', 'F'])]
    expected.index = Index(['bar', 'foo'], name='A')
    expected = expected.sort_index()
    assert_frame_equal(nth, expected)
    idx = lrange(10)
    idx.append(9)
    s = Series(data=lrange(11), index=idx, name='IntCol')
    assert (s.dtype == 'int64')
    f = s.groupby(level=0).first()
    assert (f.dtype == 'int64')
def test_first_last_nth_dtypes(self):
    df = self.df_mixed_floats.copy()
    df['E'] = True
    df['F'] = 1
    grouped = df.groupby('A')
    first = grouped.first()
    expected = df.loc[([1, 0], ['B', 'C', 'D', 'E', 'F'])]
    expected.index = Index(['bar', 'foo'], name='A')
    expected = expected.sort_index()
    assert_frame_equal(first, expected)
    last = grouped.last()
    expected = df.loc[([5, 7], ['B', 'C', 'D', 'E', 'F'])]
    expected.index = Index(['bar', 'foo'], name='A')
    expected = expected.sort_index()
    assert_frame_equal(last, expected)
    nth = grouped.nth(1)
    expected = df.loc[([3, 2], ['B', 'C', 'D', 'E', 'F'])]
    expected.index = Index(['bar', 'foo'], name='A')
    expected = expected.sort_index()
    assert_frame_equal(nth, expected)
    idx = lrange(10)
    idx.append(9)
    s = Series(data=lrange(11), index=idx, name='IntCol')
    assert (s.dtype == 'int64')
    f = s.groupby(level=0).first()
    assert (f.dtype == 'int64')