This is a follow up question to get first and last values in a groupby
How do I drop first and last rows within each group?
I have this df
df
Note: in pandas version 0.20.0 and above, ix is deprecated and the use of iloc is encouraged instead.
So the df.ix[1:-1] should be replaced by df.iloc[1:-1].
df.ix[1:-1]
df.iloc[1:-1]