drop first and last row from within each group

后端 未结 2 939
灰色年华
灰色年华 2021-01-14 13:22

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

2条回答
  •  醉梦人生
    2021-01-14 13:50

    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].

提交回复
热议问题